xcode 为 NVCC 恢复 Apple Clang 版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36250949/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Revert Apple Clang Version For NVCC
提问by Jude Michael Murphy
I am trying to run NVCC to compile a CUDA program on my Mac.
我正在尝试运行 NVCC 以在我的 Mac 上编译 CUDA 程序。
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".
当我尝试运行 NVCC 时,我收到以下错误:“nvcc 致命:不支持主机编译器('Apple clang')的版本('70300')”。
I recently updated my XCode version to 7.3, and my Mac to 10.11.4.
我最近将我的 XCode 版本更新到 7.3,我的 Mac 更新到 10.11.4。
Is there any way to revert my Clang Version?
有没有办法恢复我的 Clang 版本?
回答by szha
- 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.
- Run the following command to switch to the old version:
sudo xcode-select --switch /Library/Developer/CommandLineTools
- Run the following command to quickly check clang version:
clang --version
- 转到https://developer.apple.com/downloads/,登录然后下载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,并安装,如由 fabregaszy 建议。
- 运行以下命令切换到旧版本:
sudo xcode-select --switch /Library/Developer/CommandLineTools
- 运行以下命令可以快速查看 clang 版本:
clang --version
回答by adon
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.
在 10.11 升级到 XCode 7.3 后,我遇到了同样的问题。重新安装以前的 (7.2) 命令行工具不会降级默认的 clang 编译器。为了解决这个问题,我使用了以前的 XCode.app 包来重命名 XcodeDefault.xctoolchain 目录并将其复制到当前 /Applications/Xcode.app 中的 Toolchains 目录中。您必须右键单击 Xcode.app 以“显示包内容”,然后浏览到 Toolchains 目录。
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.
然后(重新)启动 Xcode,点击 command-,查看首选项,然后转到位置。您将看到命令行工具的下拉菜单。将其更改为您复制的工具链版本。
You can check the default version of clang in Terminal:
您可以在终端中检查 clang 的默认版本:
clang -v OR llvm-gcc -v
Now nvcc should work
现在 nvcc 应该可以工作了
回答by Hugues TALBOT
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
回答by fabregaszy
I came into the same issue.
我遇到了同样的问题。
I think the old command-line tools which can be downloaded from https://developer.apple.com/downloads/
我认为可以从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.
我从下面的链接下载并安装,clang版本成功恢复到Apple LLVM 7.0.2版本clang-700。但请留意您的 OS X 版本。
回答by J?rg
Unfortunately, installing Command Line Tools from X-code version 7.2. currently is not solving this.
不幸的是,从 X-code 7.2 版安装命令行工具。目前没有解决这个问题。
Trying to compile results in:
尝试编译结果:
nvcc fatal : GNU C/C++ compiler is no longer supported as a host compiler on Mac OS X.
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.
对我来说,诀窍是从 Apple 开发者网站卸载 Xcode 7.3 并安装 Xcode 6.2。
回答by albertxavier
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.
在您的 Mac 中将 Xcode 重命名为 /Applications 文件夹中的 Xcode-7.app。然后从https://developer.apple.com/download/more/下载 Xcode6.4并安装它。
回答by Dennis Ng
80100 can work with some nvcc programs
80100 可以与一些 nvcc 程序一起使用
I used "80100" and nvcc work for some of my other programs.
我在其他一些程序中使用了“80100”和 nvcc 工作。
... 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"
安装 CLT 8.2(来自 Apple 的命令行工具)关于“命令行工具实例”的消息是可以的
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"
我在谷歌上看到了一个关于这个(https://github.com/arrayfire/arrayfire/issues/1384)的讨论,关于 array fire nvcc 问题,感谢提示切换到 CLT 8.2,最后一个版本不是当前版本。关于“命令行工具实例”的警告消息是可以的
Need to use "sudo make" to compile sample code:
需要使用“sudo make”来编译示例代码:
` ... $ sudo make Password:
` ... $ sudo make 密码:
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)
...
`
`
回答by Dave Braford-Grimes
I would try homebrew's version of llvm, it works for me.
brew install llvm37
我会尝试自制版本的 llvm,它对我有用。
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
然后,将您的编译器设置为 homebrew 的 clang:/usr/local/bin/clang++-3.7 或任何响应
which clang++-3.7
That way you can leave your OS X dev environment defaults as they are.
这样你就可以保留你的 OS X 开发环境默认值。
回答by domlue
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).
我有同样的问题!查看我的 Time Machine Backups 并将 Xcode.app (7.2.1) 复制到我的 /Application 文件夹中。您也可以从 Apple Developer Page 下载它并将其移动到您的 /Application 文件夹中。完成后,您可以将 Xcode 首选项中的 Xcode 命令行版本更改为 7.2.1,然后 nvcc 将再次工作(即使使用 pycuda-2016.1)。
clang --version
clang --version
gives me:
给我:
Apple LLVM version 7.0.2 (clang-700.1.81)
Apple LLVM version 7.0.2 (clang-700.1.81)