当前位置: 首页 > 知识库问答 >
问题:

“make”命令使用了错误的clang编译器(来编译CUDA示例)-如何解决这个问题?

松翔
2023-03-14

我在MacOS Sierra 10.12.4上,试图让CUDA 8.0在我的MacBook Pro(2013年末)上运行,并使用与CUDA兼容的NVIDIA GeForce GT750M。

我按照NVIDIA安装指南安装了Xcode 8.2和相应的命令行工具,但是当我尝试编译示例时,我得到了以下错误:

$ make -C 1_Utilities/deviceQuery

/Developer/NVIDIA/CUDA-8.0/bin/nvcc-ccbin铛-我…/…/Common/inc-m64-Xcompiler-arch-Xcompilerx86_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-csm_20
nvcc警告:不推荐使用compute_20、deviceQuery.cpp和: *** [架构,可能会在未来的版本中删除(使用-Wno-decrecated-gpu-targ来抑制警告)。
nvcc致命:不支持主机编译器('clang')的版本('30900')
sm_21deviceQuery. o]错误1

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

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

$ clang -版本

clang版本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 -版本

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.xtoolchain/usr/bin

如何让“make”命令默认使用文件夹 /usr/bin/clang中正确的clang版本?

或者有没有办法通过添加一些参数/标签来告诉“make”命令在文件夹/usr/bin/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个答案

韩弘方
2023-03-14

通过将 make -n 作为试运行,您可以看到 make 背后的真实命令。由于我没有基于英伟达的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中进行一些更改。

如果更改生成文件,您可以轻松找到要设置的HOST_COMPILER变量。达尔文版本部分是这样的:

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

我想你可以把它改成你自己的铿锵路径。

 类似资料:
  • 我无法在GWT中编译为js。 devmode一如既往地运行良好。我在编译器之间做了很多更改,所以不知道确切的位置。 什么可以解决这个问题? [gwt 2.5 AE 1.7.1] java.lang.RuntimeException:com.google.gwt.dev.javac.ComilationUnit.getTypes(CompilationUnit.java:324)的com.goole

  • 本文向大家介绍解决Android 源码编译错误的问题,包括了解决Android 源码编译错误的问题的使用技巧和注意事项,需要的朋友参考一下 如下所示: Building with Jack: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/with-local/classes.dex FAILED: /bin/bash ou

  • 本文向大家介绍C++ 用Clang编译,包括了C++ 用Clang编译的使用技巧和注意事项,需要的朋友参考一下 示例 由于锵前端被设计为是与GCC兼容,当你交换可通过GCC编译大多数程序将编译g++通过clang++在构建脚本。如果没有-std=version给出,将使用gnu11。 习惯了MSVC的Windows用户可以cl.exe与交换clang-cl.exe。默认情况下,clang尝试与已安

  • 这些命令在用途和功能性方面与 C 预处理器很相似。它们都允许文件内含,条件编译,可执行的头部封包,以及在构建进程期间处理执行。注意:这些命令都不允许使用变量。 5.1.1 !include [/NONFATAL] 文件 这个命令可以将一个文件包含到脚本中,就像是脚本的一部分一样。请注意,如果一个文件包含在了另一个目录中,那么当前目录仍是编译脚本的地方 (不是要包含的文件所在的目录)。如果编译器无法

  • 我正在尝试对protobuf二进制文件进行原始解码。我从源代码中安装了google protobuf库https://github.com/google/protobuf我可以使用命令行来解码原始的protobuf二进制文件,使用命令