Fatal error during Mac source build

bberko: <p>Hi, I’m on a Mac with an Nvidia GeForce GT 650M, CUDA 8, Mac OS 10.14.2, and building within a Conda environment.</p>
<p>I followed the readme pretty closely, but possible I missed something. I used the following command to build:</p>
<pre><code class="lang-auto">MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py install
</code></pre>
<p>and the errors are:</p>
<pre><code class="lang-auto">[ 68%] Built target caffe2
Scanning dependencies of target caffe2_module_test_dynamic
Scanning dependencies of target THD
Scanning dependencies of target shm
Scanning dependencies of target caffe2_pybind11_state
Scanning dependencies of target caffe2_observers
[ 68%] Building NVCC (Device) object caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/THC/caffe2_gpu_generated_THCSleep.cu.o
[ 68%] Building NVCC (Device) object caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/THC/caffe2_gpu_generated_THCBlas.cu.o
[ 68%] Building NVCC (Device) object caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/THC/caffe2_gpu_generated_THCReduceApplyUtils.cu.o
[ 68%] Building CXX object caffe2/torch/lib/libshm/CMakeFiles/shm.dir/core.cpp.o
[ 68%] Building CXX object modules/module_test/CMakeFiles/caffe2_module_test_dynamic.dir/module_test_dynamic.cc.o
[ 68%] Building CXX object modules/observers/CMakeFiles/caffe2_observers.dir/net_observer_reporter_print.cc.o
In file included from &lt;built-in&gt;:1:
In file included from /usr/local/cuda/include/cuda_runtime.h:115:
In file included from In file included from &lt;built-in&gt;:1:
In file included from /usr/local/cuda/include/cuda_runtime.h:115:
In file included from In file included from &lt;built-in&gt;: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 &lt;string.h&gt;
              ^~~~~~~~~~
/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 &lt;string.h&gt;
              ^~~~~~~~~~
/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 &lt;string.h&gt;
              ^~~~~~~~~~
1 error generated.
CMake Error at caffe2_gpu_generated_THCSleep.cu.o.Release.cmake:219 (message):
  Error generating
  /Users/user/Development/pytorch/build/caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/THC/./caffe2_gpu_generated_THCSleep.cu.o


1 error generated.
make[2]: *** [caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/THC/caffe2_gpu_generated_THCSleep.cu.o] Error 1
make[2]: *** Waiting for unfinished jobs....
[ 68%] Building CXX object modules/observers/CMakeFiles/caffe2_observers.dir/observer_config.cc.o
CMake Error at caffe2_gpu_generated_THCBlas.cu.o.Release.cmake:219 (message):
  Error generating
  /Users/user/Development/pytorch/build/caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/THC/./caffe2_gpu_generated_THCBlas.cu.o


1 error generated.
make[2]: *** [caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/THC/caffe2_gpu_generated_THCBlas.cu.o] Error 1
CMake Error at caffe2_gpu_generated_THCReduceApplyUtils.cu.o.Release.cmake:219 (message):
  Error generating
  /Users/user/Development/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[1]: *** [caffe2/CMakeFiles/caffe2_gpu.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 68%] Building CXX object modules/observers/CMakeFiles/caffe2_observers.dir/perf_observer.cc.o
[ 68%] Building CXX object caffe2/torch/lib/THD/CMakeFiles/THD.dir/base/ChannelUtils.cpp.o
[ 68%] Building CXX object caffe2/torch/lib/THD/CMakeFiles/THD.dir/base/Cuda.cpp.o
[ 68%] Building CXX object caffe2/CMakeFiles/caffe2_pybind11_state.dir/python/pybind_state.cc.o
[ 68%] Linking CXX shared library ../../../../lib/libshm.dylib
[ 68%] Built target shm
[ 68%] Building CXX object caffe2/torch/lib/THD/CMakeFiles/THD.dir/base/DataChannel.cpp.o
[ 68%] Building CXX object caffe2/CMakeFiles/caffe2_pybind11_state.dir/python/pybind_state_dlpack.cc.o
[ 68%] Building CXX object caffe2/CMakeFiles/caffe2_pybind11_state.dir/python/pybind_state_nomni.cc.o
[ 68%] Building CXX object caffe2/torch/lib/THD/CMakeFiles/THD.dir/base/DataChannelRequest.cpp.o
In file included from /Users/user/Development/pytorch/torch/lib/THD/base/DataChannel.cpp:6:
/Users/user/Development/pytorch/torch/lib/THD/../THD/base/data_channels/DataChannelMPI.hpp:15:12: warning: 
      class 'DataChannelMPI' was previously declared as a struct
      [-Wmismatched-tags]
    friend class DataChannelMPI; // allows `DataChannelMPI` to access private
           ^
/Users/user/Development/pytorch/torch/lib/THD/../THD/base/data_channels/DataChannelMPI.hpp:13:8: note: 
      previous use is here
struct DataChannelMPI : DataChannel {
       ^
[ 68%] Building CXX object caffe2/CMakeFiles/caffe2_pybind11_state.dir/python/pybind_state_registry.cc.o
1 warning generated.
[ 68%] Building CXX object caffe2/CMakeFiles/caffe2_pybind11_state.dir/python/pybind_state_int8.cc.o
[ 68%] Building CXX object caffe2/torch/lib/THD/CMakeFiles/THD.dir/base/RPCType.cpp.o
[ 68%] Building CXX object caffe2/torch/lib/THD/CMakeFiles/THD.dir/base/data_channels/DataChannelMPI.cpp.o
[ 68%] Building CXX object caffe2/torch/lib/THD/CMakeFiles/THD.dir/base/data_channels/DataChannelTCP.cpp.o
[ 68%] Linking CXX shared library ../../lib/libcaffe2_module_test_dynamic.dylib
[ 68%] Building CXX object caffe2/torch/lib/THD/CMakeFiles/THD.dir/base/init_methods/InitMethod.cpp.o
[ 68%] Built target caffe2_module_test_dynamic
[ 68%] Building CXX object caffe2/CMakeFiles/caffe2_pybind11_state.dir/python/pybind_state_ideep.cc.o
In file included from /Users/user/Development/pytorch/torch/lib/THD/base/data_channels/DataChannelMPI.cpp:1:
/Users/user/Development/pytorch/torch/lib/THD/../THD/base/data_channels/DataChannelMPI.hpp:15:12: warning: 
      class 'DataChannelMPI' was previously declared as a struct
      [-Wmismatched-tags]
    friend class DataChannelMPI; // allows `DataChannelMPI` to access private
           ^
/Users/user/Development/pytorch/torch/lib/THD/../THD/base/data_channels/DataChannelMPI.hpp:13:8: note: 
      previous use is here
struct DataChannelMPI : DataChannel {
       ^
[ 68%] Linking CXX shared library ../../lib/libcaffe2_observers.dylib
[ 68%] Built target caffe2_observers
[ 68%] Building CXX object caffe2/torch/lib/THD/CMakeFiles/THD.dir/base/init_methods/InitMethodEnv.cpp.o
[ 68%] Building CXX object caffe2/torch/lib/THD/CMakeFiles/THD.dir/base/init_methods/InitMethodFile.cpp.o
[ 68%] Building CXX object caffe2/torch/lib/THD/CMakeFiles/THD.dir/base/init_methods/InitMethodTCP.cpp.o
1 warning generated.
[ 68%] Building CXX object caffe2/torch/lib/THD/CMakeFiles/THD.dir/base/init_methods/InitMethodUtils.cpp.o
[ 68%] Building CXX object caffe2/torch/lib/THD/CMakeFiles/THD.dir/process_group/Collectives.cpp.o
[ 68%] Building CXX object caffe2/torch/lib/THD/CMakeFiles/THD.dir/process_group/General.cpp.o
[ 68%] Linking CXX static library ../../../../lib/libTHD.a
[ 68%] Built target THD
[ 68%] Linking CXX shared module python/caffe2_pybind11_state.cpython-36m-darwin.so
[ 68%] Built target caffe2_pybind11_state
make: *** [all] Error 2
Traceback (most recent call last):
  File "setup.py", line 710, in &lt;module&gt;
    build_deps()
  File "setup.py", line 282, in build_deps
    build_dir='build')
  File "/Users/user/Development/pytorch/tools/build_pytorch_libs.py", line 255, in build_caffe2
    check_call(['make', '-j', str(max_jobs), 'install'], cwd=build_dir, env=my_env)
  File "/Users/user/anaconda3/envs/aenv/lib/python3.6/subprocess.py", line 291, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['make', '-j', '8', 'install']' returned non-zero exit status 2.
</code></pre>
<p>I’d love to build from source so I can utilize CUDA. How can I figure out where I’m going wrong with the build?</p>
<p>Thank you!</p>

bberko: <p>I guess regardless of the build problems, it looks like I’m not going to be able to use CUDA because Apple won’t approve its drivers for 10.14, and I’ll have to dual-boot into Linux if I want to utilize CUDA. Is that correct?</p>

shizacat: <p>Hello,<br>
I have the exact same error.<br>
Maybe do someone found a solution to build under 10.14?</p>
<p>Find this topic <a href="https://devtalk.nvidia.com/default/topic/1042279/cuda-setup-and-installation/cuda-10-and-macos-10-14/" rel="nofollow noopener">CUDA 10 and macOS 10.14</a></p>
<p>Version 1.1.0 was recently released, the error has changed to</p>
<pre><code class="lang-auto">[10/901] Building NVCC (Device) object caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/THC/generated/caffe2_gpu_generated_THCTensorSortByte.cu.o
FAILED: caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/THC/generated/caffe2_gpu_generated_THCTensorSortByte.cu.o
cd /Users/shizacat/Projects/dlcourse_ai/tmp/pytorch/build/caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/THC/generated &amp;&amp; /Users/shizacat/anaconda3/bin/cmake -E make_directory /Users/shizacat/Projects/dlcourse_ai/tmp/pytorch/build/caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/THC/generated/. &amp;&amp; /Users/shizacat/anaconda3/bin/cmake -D verbose:BOOL=OFF -D build_configuration:STRING=Release -D generated_file:STRING=/Users/shizacat/Projects/dlcourse_ai/tmp/pytorch/build/caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/THC/generated/./caffe2_gpu_generated_THCTensorSortByte.cu.o -D generated_cubin_file:STRING=/Users/shizacat/Projects/dlcourse_ai/tmp/pytorch/build/caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/THC/generated/./caffe2_gpu_generated_THCTensorSortByte.cu.o.cubin.txt -P /Users/shizacat/Projects/dlcourse_ai/tmp/pytorch/build/caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/THC/generated/caffe2_gpu_generated_THCTensorSortByte.cu.o.Release.cmake
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/new(243): error: too many arguments in function call

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/new(263): error: too many arguments in function call

/usr/local/cuda/include/crt/math_functions.h(8909): error: cannot overload functions distinguished by return type alone

/usr/local/cuda/include/crt/math_functions.h(8911): error: cannot overload functions distinguished by return type alone

/usr/local/cuda/include/crt/math_functions.h(8913): error: cannot overload functions distinguished by return type alone

/usr/local/cuda/include/crt/math_functions.h(8915): error: cannot overload functions distinguished by return type alone

/usr/local/cuda/include/crt/math_functions.hpp(157): error: cannot overload functions distinguished by return type alone

/usr/local/cuda/include/crt/math_functions.hpp(159): error: cannot overload functions distinguished by return type alone

/usr/local/cuda/include/crt/math_functions.hpp(161): error: cannot overload functions distinguished by return type alone

/usr/local/cuda/include/crt/math_functions.hpp(163): error: cannot overload functions distinguished by return type alone

/Users/shizacat/Projects/dlcourse_ai/tmp/pytorch/c10/util/UniqueVoidPtr.h(69): warning: attribute namespace "clang" is unrecognized

/Users/shizacat/Projects/dlcourse_ai/tmp/pytorch/c10/core/Allocator.h(96): warning: attribute namespace "clang" is unrecognized

/Users/shizacat/Projects/dlcourse_ai/tmp/pytorch/c10/core/TensorOptions.h(171): warning: attribute namespace "clang" is unrecognized

/Users/shizacat/Projects/dlcourse_ai/tmp/pytorch/c10/core/TensorOptions.h(181): warning: attribute namespace "clang" is unrecognized

/Users/shizacat/Projects/dlcourse_ai/tmp/pytorch/c10/core/TensorOptions.h(190): warning: attribute namespace "clang" is unrecognized

/Users/shizacat/Projects/dlcourse_ai/tmp/pytorch/c10/core/TensorOptions.h(195): warning: attribute namespace "clang" is unrecognized

/Users/shizacat/Projects/dlcourse_ai/tmp/pytorch/c10/core/TensorOptions.h(202): warning: attribute namespace "clang" is unrecognized

/Users/shizacat/Projects/dlcourse_ai/tmp/pytorch/c10/core/TensorOptions.h(217): warning: attribute namespace "clang" is unrecognized

/Users/shizacat/Projects/dlcourse_ai/tmp/pytorch/c10/core/TensorOptions.h(224): warning: attribute namespace "clang" is unrecognized

/Users/shizacat/Projects/dlcourse_ai/tmp/pytorch/c10/core/TensorOptions.h(231): warning: attribute namespace "clang" is unrecognized

/Users/shizacat/Projects/dlcourse_ai/tmp/pytorch/c10/core/TensorOptions.h(239): warning: attribute namespace "clang" is unrecognized

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/tuple(177): error: type name is not allowed
</code></pre>