Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set default host compiler for nvcc

Tags:

cuda

clang

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?

like image 528
Chris Avatar asked Jun 28 '17 01:06

Chris


1 Answers

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
like image 90
osgx Avatar answered Sep 18 '22 19:09

osgx