Can't build from source on macOS 10.14 for CUDA support: "no member named 'out_of_range' in namespace 'std'"

atineoSE: <p>I am following the instructions of the <a href="https://pytorch.org/get-started/locally/#build" rel="nofollow noopener">get started page</a> of Pytorch site to build pytorch with CUDA support on mac OS 10.14 (Mojave) but I am getting an error:</p>
<pre><code class="lang-auto">[ 80%] Building CXX object caffe2/CMakeFiles/torch.dir/__/torch/csrc/jit/passes/alias_analysis.cpp.o
In file included from /Users/adriantineo/dev/python/pytorch/torch/csrc/jit/passes/alias_analysis.cpp:1:
In file included from /Users/adriantineo/dev/python/pytorch/torch/csrc/jit/passes/alias_analysis.h:3:
/Users/adriantineo/dev/python/pytorch/c10/util/flat_hash_map.h:1367:24: error: no
      member named 'out_of_range' in namespace 'std'
            throw std::out_of_range("Argument passed to at() was not in the map.");
                  ~~~~~^
/Users/adriantineo/dev/python/pytorch/c10/util/flat_hash_map.h:1374:24: error: no
      member named 'out_of_range' in namespace 'std'
            throw std::out_of_range("Argument passed to at() was not in the map.");
                  ~~~~~^
[ 80%] Building CXX object caffe2/CMakeFiles/torch.dir/__/torch/csrc/jit/passes/batch_mm.cpp.o
[ 80%] Building CXX object caffe2/CMakeFiles/torch.dir/__/torch/csrc/jit/passes/bailout_graph.cpp.o
[ 80%] Building CXX object caffe2/CMakeFiles/torch.dir/__/torch/csrc/jit/passes/canonicalize.cpp.o
[ 80%] Building CXX object caffe2/CMakeFiles/torch.dir/__/torch/csrc/jit/passes/constant_propagation.cpp.o
[ 80%] Building CXX object caffe2/CMakeFiles/torch.dir/__/torch/csrc/jit/passes/constant_pooling.cpp.o
[ 81%] Building CXX object caffe2/CMakeFiles/torch.dir/__/torch/csrc/jit/passes/common_subexpression_elimination.cpp.o
2 errors generated.
make[2]: *** [caffe2/CMakeFiles/torch.dir/__/torch/csrc/jit/passes/alias_analysis.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [caffe2/CMakeFiles/torch.dir/all] Error 2
make: *** [all] Error 2
Traceback (most recent call last):
  File "setup.py", line 749, in &lt;module&gt;
    build_deps()
  File "setup.py", line 323, in build_deps
    cmake=cmake)
  File "/Users/adriantineo/dev/python/pytorch/tools/build_pytorch_libs.py", line 64, in build_caffe2
    cmake.build(my_env)
  File "/Users/adriantineo/dev/python/pytorch/tools/setup_helpers/cmake.py", line 340, in build
    self.run(build_args, my_env)
  File "/Users/adriantineo/dev/python/pytorch/tools/setup_helpers/cmake.py", line 93, in run
    check_call(command, cwd=self.build_dir, env=env)
  File "/Users/adriantineo/anaconda3/lib/python3.7/subprocess.py", line 347, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--target', 'install', '--config', 'Release', '--', '-j', '8']' returned non-zero exit status 2.
</code></pre>
<p>I have followed the steps for the prerequisites as stated in the documentation. I am using Anaconda 4.7.5, Python 3.7.3, and CUDA Toolkit 10.1 Update.</p>
<p>On top of that, I am using Xcode command line tools for Xcode 8.2, since the ones for Xcode 10 were giving trouble with the error message <code>fatal error: 'string.h' file not found</code>. I found the tip to use an older version of Xcode command line tools <a href="https://github.com/pytorch/pytorch/issues/4049#issuecomment-357154695" rel="nofollow noopener">here</a>.</p>
<p>Any tips to troubleshoot the build?</p>

atineoSE: <p>More info about the build:</p>
<pre><code class="lang-auto">-- ******** Summary ********
--   CMake version         : 3.14.5
--   CMake command         : /Users/adriantineo/anaconda3/bin/cmake
--   System                : Darwin
--   C++ compiler          : /Library/Developer/CommandLineTools/usr/bin/clang++
--   C++ compiler version  : 8.0.0.8000042
--   CXX flags             :   -Wno-deprecated -fvisibility-inlines-hidden -Wno-deprecated-declarations -Wnon-virtual-dtor
--   Build type            : Release
--   Compile definitions   : TH_BLAS_MKL;ONNX_ML=1
--   CMAKE_PREFIX_PATH     : /Users/adriantineo/anaconda3/lib/python3.7/site-packages
--   CMAKE_INSTALL_PREFIX  : /Users/adriantineo/dev/python/pytorch/torch
--   CMAKE_MODULE_PATH     : /Users/adriantineo/dev/python/pytorch/cmake/Modules;/Users/adriantineo/dev/python/pytorch/cmake/public/../Modules_CUDA_fix
-- 
--   ONNX version          : 1.5.0
--   ONNX NAMESPACE        : onnx_torch
--   ONNX_BUILD_TESTS      : OFF
--   ONNX_BUILD_BENCHMARKS : OFF
--   ONNX_USE_LITE_PROTO   : OFF
--   ONNXIFI_DUMMY_BACKEND : OFF
--   ONNXIFI_ENABLE_EXT    : OFF
-- 
--   Protobuf compiler     : 
--   Protobuf includes     : 
--   Protobuf libraries    : 
--   BUILD_ONNX_PYTHON     : OFF
--
</code></pre>
<p>[…]</p>
<pre><code class="lang-auto">--   USE_CUDA              : True
--     CUDA static link    : OFF
--     USE_CUDNN           : OFF
--     CUDA version        : 10.1
--     CUDA root directory : /usr/local/cuda
--     CUDA library        : /usr/local/cuda/lib/libcuda.dylib
--     cudart library      : /usr/local/cuda/lib/libcudart.dylib
--     cublas library      : /usr/local/cuda/lib/libcublas.dylib
--     cufft library       : /usr/local/cuda/lib/libcufft.dylib
--     curand library      : /usr/local/cuda/lib/libcurand.dylib
--     nvrtc               : /usr/local/cuda/lib/libnvrtc.dylib
--     CUDA include path   : /usr/local/cuda/include
--     NVCC executable     : /usr/local/cuda/bin/nvcc
--     CUDA host compiler  : /Library/Developer/CommandLineTools/usr/bin/clang
</code></pre>

Carlos_Alvarez_Arism: <p>it’s probably because mac os Mojave (10.14) and Catalina (10.15) do not support cuda drivers. I downgraded to my os to High Sierra (10.13)</p>