从源代码构建Pytorch

问题描述 投票:2回答:1

我正在尝试从我的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.
python macos pytorch
1个回答
1
投票

/Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:61:15:fatal error:'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
© www.soinside.com 2019 - 2024. All rights reserved.