我使用的是MacOS Sierra 10.12.4,并尝试使用兼容CUDA的NVIDIA GeForce GT 750M在我的MacBook Pro(2013年末)上运行CUDA 8.0 .
我按照NVIDIA installation guide安装了Xcode 8.2和相应的命令行工具,但是当我尝试编译样本时,我收到以下错误:
$ make -C 1_Utilities / deviceQuery /Developer/NVIDIA/CUDA-8.0/bin/nvcc -ccbin clang -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:'compute_20','sm_20'和'sm_21'体系结构已弃用,可能会被删除将来的版本(使用-Wno-deprecated-gpu-targets来抑制警告) . nvcc致命:不支持主机编译器('clang')的版本('30900')make:*** [deviceQuery.o]错误1
我想这是问题所在:
"make"命令使用了错误的clang,但我不知道如何更改/修复此问题 .
在这里你可以看到我的机器上的两个版本的clang:
$ clang --version clang version 3.9.0(tags / RELEASE_390 / final)目标:x86_64-apple-darwin16.5.0线程模型:posix InstalledDir:/opt/local/libexec/llvm-3.9/bin $ / usr / bin / clang --version Apple LLVM 8.0.0版(clang-800.0.42.1)目标:x86_64-apple-darwin16.5.0线程模型:posix InstalledDir:/Applications/Xcode_8.2.app/Contents/Developer/Toolchains/XcodeDefault . xctoolchain在/ usr / bin中
如何在默认情况下使“make”命令在/ usr / bin / clang文件夹中使用正确的clang版本?
或者有没有办法告诉“make”命令通过添加一些参数/标签显式使用文件夹/ usr / bin / clang中的clang版本?
这也是我的〜/ .bash_profile看起来如何有用:
# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
# MacPorts Installer addition on 2016-09-26_at_12:06:30: adding an appropriate PATH variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
# Finished adapting your PATH environment variable for use with MacPorts.
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
# colorful terminal
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -GFh'
# CUDA
export PATH=/Developer/NVIDIA/CUDA-8.0.61/bin${PATH:+:${PATH}}
export DYLD_LIBRARY_PATH=/Developer/NVIDIA/CUDA-8.0.61/lib\
${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}
1 回答
通过
make -n
作为干运行,您可以看到make
背后的真实命令 . 因为我不会以Linux版本为例向您展示:您可以看到
-ccbin
(或--compiler-bindir
)是设置主机编译器的实际参数 . 另外nvcc --help
会告诉你这个论点 .然后您可以手动运行
nvcc
或尝试在Makefile
中进行一些更改 .如果更改
Makefile
,您可以轻松找到要设置的HOST_COMPILER
变量 . 而darwin版本的部分是这样的:我想你可以把它改成你自己的clang路径 .