Search code examples
cudaclangpytorchmacos-sierranvcc

nvcc and clang are not working well together when installing pytorch-gpu


I am trying to install pytorch with gpu support on my MacBook Pro following official instructions.

Things go smoothly until an error occurred:

[ 70%] Building NVCC (Device) object caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/THC/caffe2_gpu_generated_THCTensorMath.cu.o
nvcc fatal   : The version ('90000') of the host compiler ('Apple clang') is not supported
nvcc fatal   : The version ('90000') of the host compiler ('Apple clang') is not supported
CMake Error at caffe2_gpu_generated_THCBlas.cu.o.Release.cmake:219 (message):
  Error generating
  /Users/username/Dev/pytorch-gpu/pytorch/build/cCaMfafkee2 /ECrMraokre Faitle sc/acfaffef2e_2g_pgup_ug.ednierr/a_t_e/da_tTeHnC/Sslrece/pT.HcCu/..o/.cRaeflfeea2s_eg.pcum_agkeen:e2r1a9t e(dm_eTsHsCaBglea)s:.

It seems that CUDA and clang are not working well together.

I searched over internet and found these posts, but they did not solve my problem:

Here's my environment:

  • macOS Sierra 10.12.6 (16G1618)
  • NVIDIA GeForce GT 750M
  • CUDA Driver Version: 387.178
  • GPU Driver Version: 378.05.05.25f11
  • Cuda compilation tools, release 8.0, V8.0.61
  • (Previous)Apple LLVM version 9.0.0 (clang-900.0.39.2)
  • (After downgrade)Apple LLVM version 8.1.0 (clang-802.0.42)
  • Xcode Version 9.2 (9C40b)

Solution

  • I am answering my own question.

    Incorrect CUDA installation on macOS could be a nightmare. The versions of CUDA, Xcode, clang and macOS really matter. Here are some of the official tested ones:

    +------+--------------+------------+---------------------------------+--------+
    | CUDA |    Xcode     | Apple LLVM | Mac OSX Version (native x86_64) | Yes/No |
    +------+--------------+------------+---------------------------------+--------+
    | 8.0  | 7.2          | 7.0.3      | 10.11                           | YES    |
    | 8.0  | 7.2          | 7.0.3      | 10.12                           | NO     |
    | 8.0  | 8.2          | 8.0.0      | 10.11                           | NO     |
    | 8.0  | 8.2          | 8.0.0      | 10.12                           | YES    |
    | 9.0  | 8.3.3        | 8.1.0      | 10.12                           | YES    |
    | 9.1  | 9.2          | 9.0.0      | 10.13.3                         | YES    |
    | 9.2  | 9.2          | 9.0.0      | 10.13.5                         | YES    |
    | 10.0 | 9.4          | 9.0.0      | 10.13.6                         | YES    |
    | 10.1 | 10.1 (10B61) | 10.0.0     | 10.13.6 (17G2307)               | YES    |
    +------+--------------+------------+---------------------------------+--------+
    

    For CUDA Releases before 8.0, please search for NVIDIA CUDA INSTALLATION GUIDE FOR MAC OS X plus the CUDA version number, there should be a table of version matching in that PDF file.