3

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.
4
  • What happens if you cd into the source directory (i.e., wherever the Makefile is) and run make -j 4 install ? Commented Mar 11, 2019 at 17:41
  • I have the following error ModuleNotFoundError: No module named '__main__.setup_helpers'; '__main__' is not a package before running make -j 4 install Commented Mar 11, 2019 at 17:50
  • There should be more details about the actual issue printed, before the message you provided. Can you find this info? Commented Mar 11, 2019 at 18:08
  • I didn't see it. I have updated my post. Commented Mar 11, 2019 at 22:31

2 Answers 2

2

/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
Sign up to request clarification or add additional context in comments.

9 Comments

I install again Xcode and I found string.h in the good folder but the installation of PyTorch gives me the same error I described.
@Jonor: Be sure to clean the cmake build cache.
I'm sorry, I don't know how can I do it. Can you explain or I will have a look on the web
@Jonor: cd into pytorch directory and rm -rf build. When you say you have the same error, it’s “file not found”, string.h?
@Jonor: Okay that’s what you want; If that doesn’t resolve it then there’s a couple other suggestions I might have, although hopefully this will do it.
|
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.