Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build Pytorch from source

I'm trying to install Pytorch from source on my MacOS (version 10.14.3) to use GPU. I have follow the documentation from this link. When I launch in my terminal the MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py install I'm getting the following error in my terminal:

[ 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.

I tried to upgrade pip and reinstall anaconda and cuda without success.

Here you can find the error just belong :

[ 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.
like image 625
Jonor Avatar asked Jul 11 '26 23:07

Jonor


2 Answers

/Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:61:15:fatal error: 'string.h' file not found

It appears you are missing the C++ header string.h; my suggestion would be to try to install/reinstall the Xcode Command-Line tools if you haven't already:

$ xcode-select --install

If the command-line tools are already installed then perhaps uninstall (by removing the directory):

$ rm -rf /Library/Developer/CommandLineTools

Once done removing try the first command again, then check to see if string.h is installed:

$ find /Library/Developer/CommandLineTools/usr -type f -name string.h
/Library/Developer/CommandLineTools/usr/include/c++/v1/string.h
like image 139
l'L'l Avatar answered Jul 13 '26 12:07

l'L'l


I was encountering this problem because Nvidia is incompatible with OSX Mojave 10.14+

like image 40
rohaldb Avatar answered Jul 13 '26 14:07

rohaldb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!