Revert Apple Clang Version For NVCC

2019-03-08 06:17发布

问题:

I am trying to run NVCC to compile a CUDA program on my Mac.

When I try to run NVCC, I am receiving the following error: "nvcc fatal : The version ('70300') of the host compiler ('Apple clang') is not supported".

I recently updated my XCode version to 7.3, and my Mac to 10.11.4.

Is there any way to revert my Clang Version?

回答1:

  1. Go to https://developer.apple.com/downloads/, log in and then download http://adcdownload.apple.com/Developer_Tools/Command_Line_Tools_OS_X_10.11_for_Xcode_7.2/Command_Line_Tools_OS_X_10.11_for_Xcode_7.2.dmg, and install, as was suggested by fabregaszy.
  2. Run the following command to switch to the old version: sudo xcode-select --switch /Library/Developer/CommandLineTools
  3. Run the following command to quickly check clang version: clang --version


回答2:

I just had the same issue after upgrading to XCode 7.3 on 10.11. Reinstalling the previous (7.2) command line tools didn't downgrade the default clang compiler. To fix this I used a previous XCode.app package to rename and copy the XcodeDefault.xctoolchain directory into the Toolchains director in the current /Applications/Xcode.app. You have to right click on Xcode.app to "Show package contents" then browse to the Toolchains dir.

Then (re)start Xcode, hit command-, for preferences, then go to locations. You will see the dropdown for Command Line Tools. Change this to the version of the toolchain you copied over.

You can check the default version of clang in Terminal:

clang -v OR llvm-gcc -v

Now nvcc should work



回答3:

The accepted answer says to download the next-to-latest command line tools and install them, then select them by typing in the console

sudo xcode-select --switch /Library/Developer/CommandLineTools

Its been asked how to revert to the original version of the tools. This is achieved by

sudo xcode-select --switch /Applications/Xcode.app


回答4:

I came into the same issue.

I think the old command-line tools which can be downloaded from https://developer.apple.com/downloads/

may solve this issue.

Updated:

I downloaded from the link below and installed, the clang version was successfully reverted to Apple LLVM version 7.0.2 clang-700. But please keep an eye on your OS X version.

http://adcdownload.apple.com/Developer_Tools/Command_Line_Tools_OS_X_10.11_for_Xcode_7.2/Command_Line_Tools_OS_X_10.11_for_Xcode_7.2.dmg



回答5:

I would try homebrew's version of llvm, it works for me. brew install llvm37

Then, set your compiler to homebrew's clang: /usr/local/bin/clang++-3.7 or whatever respondes to which clang++-3.7

That way you can leave your OS X dev environment defaults as they are.



回答6:

Unfortunately, installing Command Line Tools from X-code version 7.2. currently is not solving this.

Trying to compile results in:

nvcc fatal : GNU C/C++ compiler is no longer supported as a host compiler on Mac OS X.

What did the trick for me, was to uninstall Xcode 7.3 and install Xcode 6.2 from the Apple developer site.



回答7:

Rename Xcode exists in your mac as Xcode-7.app in /Applications folder. Then download Xcode6.4 from https://developer.apple.com/download/more/ and install it.



回答8:

80100 can work with some nvcc programs

I used "80100" and nvcc work for some of my other programs.

... but not sample

`

...
nvcc fatal   : The version ('80100') of the host compiler ('Apple clang') is not supported
...

`

install CLT 8.2 (Command line tool from Apple) it is sort of ok with message about "command line tools instance"

I google and see a discussion about this (https://github.com/arrayfire/arrayfire/issues/1384) about array fire nvcc issue and thanks to the hint to switch to CLT 8.2, the last version not current one. It is sort of ok with warning message about "command line tools instance"

Need to use "sudo make" to compile sample code:

` ... $ sudo make Password:

xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
expr: syntax error

/Developer/NVIDIA/CUDA-8.0/bin/nvcc -ccbin g++ -I../../common/inc  -m64  -Xcompiler -arch -Xcompiler x86_64  -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_60,code=compute_60 -o deviceQuery.o -c deviceQuery.cpp

nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).

/Developer/NVIDIA/CUDA-8.0/bin/nvcc -ccbin g++   -m64  -Xcompiler -arch -Xcompiler x86_64  -Xlinker -rpath -Xlinker /Developer/NVIDIA/CUDA-8.0/lib  -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_60,code=compute_60 -o deviceQuery deviceQuery.o 

nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).

mkdir -p ../../bin/x86_64/darwin/release

cp deviceQuery ../../bin/x86_64/darwin/release

$ ./deviceQuery
./deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)
...

`



回答9:

I had the same problem! Looked in my Time Machine Backups and copied Xcode.app (7.2.1) in my /Application folder. You could also download it from the Apple Developer Page and move it into your /Application folder. After it's done, you can change the Xcode Command Line Version in your Preferences of Xcode to 7.2.1 Then nvcc will work again (even with pycuda-2016.1).

clang --version

gives me:

Apple LLVM version 7.0.2 (clang-700.1.81)