我正在尝试从MacOS(版本10.14.3)上的源代码安装Pytorch以使用GPU。我已遵循此link中的文档。当我在终端机中启动MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py install
时,终端机出现以下错误:
[ 69%] Built target caffe2_observers make: *** [all] Error 2 Traceback (most recent
call last): File "setup.py", line 710, in <module>
build_deps()
File "setup.py", line 282, in build_deps
build_dir='build')
File "/Users/Desktop/pytorch/tools/build_pytorch_libs.py", line 259, in build_caffe2
check_call(['make', '-j', str(max_jobs), 'install'], cwd=build_dir, env=my_env)
File "/Users/anaconda3/lib/python3.6/subprocess.py", line 291, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['make', '-j', '4', 'install']'
returned non-zero exit status 2.
我尝试升级pip并重新安装anaconda和cuda,但没有成功。
在这里您可以找到错误所在:
[ 69%] Building CXX object modules/observers/CMakeFiles/caffe2_observers.dir/net_observer_reporter_print.cc.o
In file included from <built-in>:1:
In file included from /usr/local/cuda/include/cuda_runtime.h:115:
In file included from /usr/local/cuda/include/crt/common_functions.h:77:
/Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:61:15: fatal error: 'string.h' file not found
#include_next <string.h>
^~~~~~~~~~
1 error generated.
CMake Error at caffe2_gpu_generated_THCReduceApplyUtils.cu.o.Release.cmake:219 (message):
Error generating
/Users/Desktop/pytorch/build/caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/THC/./caffe2_gpu_generated_THCReduceApplyUtils.cu.o
make[2]: *** [caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/THC/caffe2_gpu_generated_THCReduceApplyUtils.cu.o] Error 1
make[2]: *** Waiting for unfinished jobs....
Scanning dependencies of target torch_shm_manager
1 error generated.
答案 0 :(得分:1)
/ Library / Developer / CommandLineTools / usr / include / c ++ / v1 / string.h:61:15:致命错误:未找到“ string.h”文件 >
似乎您缺少C++
标头string.h
;我的建议是尝试安装/重新安装Xcode命令行工具,如果您还没有的话:
$ xcode-select --install
如果已经安装了命令行工具,则可以卸载(通过删除目录):
$ rm -rf /Library/Developer/CommandLineTools
完成删除后,请再次尝试第一个命令,然后检查是否安装了string.h
:
$ find /Library/Developer/CommandLineTools/usr -type f -name string.h
/Library/Developer/CommandLineTools/usr/include/c++/v1/string.h
答案 1 :(得分:1)
我遇到此问题是因为Nvidia与OSX Mojave 10.14+不兼容