问题描述
我刚刚在新的GPU服务器上安装了Debian Stretch(9)和Cuda 8。 Stretch不随旧版gcc一起提供,因此我需要使用clang作为主机编译器(nvcc不支持gcc-6)。我可以这样调用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
有没有办法在整个系统范围内实现-例如在CUDA配置或环境变量?
Is there any way to acheive this system wide - e.g. in cuda config or an environment variable?
推荐答案
nvcc的文档没有列出任何可更改ccbin的env变量,只有以下选项:
Documentation of nvcc does not list any env variable to change ccbin, only the option:
Linux指南也没有这样的信息:
Linux guide have no such info too: http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html
您可以尝试创建一些nvcc包装器脚本,并将其更早地放入PATH env var中,例如:
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
(在使用 nvcc之前,在每个新shell中重复执行
或将其添加到您的 export
的最后一行 .bashrc
或其他shell初始化脚本中)
(repeat last line with export
in every new shell before using nvcc
or add it to your .bashrc
or other shell init script)
PS:和nvcc也是bash脚本,您可以复制并编辑:
PS: and nvcc is bash script too, you can just copy it and edit:
cat `which nvcc`
更新:到cuda的内部目录 / usr / local / cuda / bin /
:
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
这篇关于设置nvcc的默认主机编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!