Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
977 views
in Technique[技术] by (71.8m points)

cuda - Set default host compiler for nvcc

I have just installed Debian Stretch (9) and Cuda 8 on a new GPU server. Stretch does not come with older versions of gcc, so I need to use clang as the host compiler (nvcc does not support gcc-6). I can do this invoking nvcc as:

nvcc -ccbin clang-3.8

Is there any way to acheive this system wide - e.g. in cuda config or an environment variable?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Documentation of nvcc does not list any env variable to change ccbin, only the option:

http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html

--compiler-bindir directory, -ccbin Specify the directory in which the compiler executable resides. The host compiler executable name can be also specified to ensure that the correct host compiler is selected.

Linux guide have no such info too: http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html

You may try creating some nvcc wrapper script and putting it earlier in the PATH env var like:

mkdir ~/supernvcc
echo '#!/bin/sh' > ~/supernvcc/nvcc
echo `which nvcc` -ccbin clang-3.8 '$@' >> ~/supernvcc/nvcc
chmod +x ~/supernvcc/nvcc
export PATH=/home/`id -un`/supernvcc:$PATH

(repeat last line with export in every new shell before using nvcc or add it to your .bashrc or other shell init script)

PS: and nvcc is bash script too, you can just copy it and edit:

cat `which nvcc`

UPDATE: People recommend to link correct gcc version to the internal dir /usr/local/cuda/bin/ of cuda:

  sudo ln -s /usr/bin/gcc-4.4 /usr/local/cuda/bin/gcc

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...