&引用;制造;命令使用错误的clang编译器(编译CUDA示例)-如何修复此问题?

&引用;制造;命令使用错误的clang编译器(编译CUDA示例)-如何修复此问题?,cuda,clang,nvidia,macos-sierra,Cuda,Clang,Nvidia,Macos Sierra,我现在使用MacOS Sierra 10.12.4,并尝试使用兼容CUDA的NVIDIA GeForce GT 750M使CUDA 8.0在我的MacBook Pro(2013年底)上运行 我遵循并安装了Xcode 8.2和相应的命令行工具,但当我尝试编译示例时,出现以下错误: $make-C 1_实用程序/设备查询 /Developer/NVIDIA/CUDA-8.0/bin/nvcc-ccbin clang++-I..//common/inc-m64-Xcompiler-arch-Xcomp

我现在使用MacOS Sierra 10.12.4,并尝试使用兼容CUDA的NVIDIA GeForce GT 750M使CUDA 8.0在我的MacBook Pro(2013年底)上运行

我遵循并安装了Xcode 8.2和相应的命令行工具,但当我尝试编译示例时,出现以下错误:

$make-C 1_实用程序/设备查询

/Developer/NVIDIA/CUDA-8.0/bin/nvcc-ccbin clang++-I..//common/inc-m64-Xcompiler-arch-Xcompiler-x86\u 64-gencode-arch=compute\u 20,code=sm\u 20-gencode-arch=compute\u 30,code=sm\u 30-gencode-arch=compute\u 35,code=sm\u 35-gencode-arch=compute\u 37,code=sm\u 37-gencode-arch=compute\u 50,code=sm\u 50-gencode=compute\u 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警告:“compute_20”、“sm_20”和“sm_21”体系结构已弃用,可能会在将来的版本中删除(使用-Wno弃用的gpu目标来抑制警告)。
nvcc致命:不支持主机编译器(“clang”)的版本('30900')
make:**[deviceQuery.o]错误1

我想问题出在这里:
“make”命令使用了错误的叮当声,但我不知道如何更改/修复此问题

在这里,您可以看到我的机器上的两个版本的clang:

$clang--版本

clang版本3.9.0(标签/发行版\u 390/最终版)
目标:x86_64-apple-darwin16.5.0 线程型号:posix
InstalledDir:/opt/local/libexec/llvm-3.9/bin

$/usr/bin/clang--版本

苹果LLVM 8.0.0版(clang-800.0.42.1)
目标:x86_64-apple-darwin16.5.0
线程模型:posix InstalledDir:/Applications/Xcode_8.2.app/Contents/Developer/toolschains/XcodeDefault.xctoolschain/usr/bin

默认情况下,如何使“make”命令在/usr/bin/clang文件夹中使用正确的clang版本

或者通过添加一些参数/标记,有没有办法告诉“make”命令显式使用/usr/bin/clang文件夹中的clang版本

下面是我的~/.bash_配置文件的外观,如果这有帮助的话:

# 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}}

通过将
make-n
作为试运行,您可以看到
make
背后的真正命令。由于我没有基于nvidia的mac,我将向您展示linux版本作为示例:

"/usr/local/cuda-8.0"/bin/nvcc -ccbin g++ -I../../common/inc  -m64    -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
"/usr/local/cuda-8.0"/bin/nvcc -ccbin g++   -m64      -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
mkdir -p ../../bin/x86_64/linux/release
cp deviceQuery ../../bin/x86_64/linux/release
您可以看到
-ccbin
(或
-compiler bindir
)是设置主机编译器的实际参数。另外,
nvcc--help
将告诉您有关此参数的信息

然后,您可以手动运行
nvcc
,或者尝试在
Makefile
中进行一些更改

如果更改
生成文件
,您可以很容易地找到要设置的
主机编译器
变量。达尔文版本的部分是这样的:

ifeq ($(TARGET_OS),darwin)
    ifeq ($(shell expr `xcodebuild -version | grep -i xcode | awk '{print $$2}' | cut -d'.' -f1` \>= 5),1)
        HOST_COMPILER ?= clang++
    endif

我想你可以把它改成你自己的叮当声。

通过
make-n
作为一个试运行,你可以看到
make
背后真正的命令。由于我没有基于nvidia的mac,我将向您展示linux版本作为示例:

"/usr/local/cuda-8.0"/bin/nvcc -ccbin g++ -I../../common/inc  -m64    -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
"/usr/local/cuda-8.0"/bin/nvcc -ccbin g++   -m64      -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
mkdir -p ../../bin/x86_64/linux/release
cp deviceQuery ../../bin/x86_64/linux/release
您可以看到
-ccbin
(或
-compiler bindir
)是设置主机编译器的实际参数。另外,
nvcc--help
将告诉您有关此参数的信息

然后,您可以手动运行
nvcc
,或者尝试在
Makefile
中进行一些更改

如果更改
生成文件
,您可以很容易地找到要设置的
主机编译器
变量。达尔文版本的部分是这样的:

ifeq ($(TARGET_OS),darwin)
    ifeq ($(shell expr `xcodebuild -version | grep -i xcode | awk '{print $$2}' | cut -d'.' -f1` \>= 5),1)
        HOST_COMPILER ?= clang++
    endif
我想你可以把它改成你自己的叮当声路径。

非常感谢,在make文件中用“/usr/bin/clang”替换“clang++”修复了问题:)非常感谢,在make文件中用“/usr/bin/clang”替换“clang++”修复了问题:)