How to compile a CUDA program with an specific toolkit version? - cuda

I have cuda toolkit 5.5 and 5.0 installed in my ubuntu system,I want to compile the .cu file with specific version..how to do that ?

You could do that by setting proper environment variables. The following example is for CUDA 5.5 on x86_64 machine.
export CUDA_HOME=/usr/local/cuda-5.5
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
export PATH=${CUDA_HOME}/bin:${PATH}

Related

nvcc not found but cuda runs fine?

I was trying to run nvcc -V to check cuda version but I got the following error message.
Command 'nvcc' not found, but can be installed with:
sudo apt install nvidia-cuda-toolkit
But gpu acceleration is working fine for training models on cuda. Is there another way to find out cuda compiler tools version. I know nvidia-smi doesn't give the right version.
Is there a way to install or configure nvcc. So I don't have to install a whole new toolkit.
Most of the time, nvcc and other CUDA SDK binaries are not in the environment variable PATH. Check the installation path of CUDA; if it is installed under /usr/local/cuda, add its bin folder to the PATH variable in your ~/.bashrc:
export CUDA_HOME=/usr/local/cuda
export PATH=${CUDA_HOME}/bin:${PATH}
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:$LD_LIBRARY_PATH
You can apply the changes with source ~/.bashrc, or the next time you log in, everything is set automatically.
As #pQB and #talonmies above mentioned you only need to install the GPU drivers (Versioned 430-470 these days) to use PyTorch. If you are using your GPU display port you should be fine.
For Cuda compilation tools you need to install the whole toolkit, which includes the driver as well. If installing manually from CLI the downloaded file, CLI will give you the option to choose the components to install or skip.
Generally, it is recommended to install the compilation tools (which are system wide) and GPU drivers together because it avoids compatibility issues.
Append:
export PATH="/usr/local/cuda/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda/lib64:$LD_LIBRARY_PATH"
to
~/.bashrc
Note: your path to cuda may include a version so navigate to /usr/local/ and check for cudaXX.XX and modify the command to point to that in ~/.bashrc

CUDA on Ubuntu 16.04

I am installing CUDA from this link.
Though it is a CUDA SDK 9.2, when I check the version installed using nvcc --version, I get the following results:
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2015 NVIDIA Corporation
Built on Tue_Aug_11_14:27:32_CDT_2015
Cuda compilation tools, release 7.5, V7.5.17
I am new to CUDA and wanted to check if this is expected. Should I expect 9.2 as the CUDA version post installation?
FYI - GPU is GeForce GTX 1080 Ti
You need to follow the official guide step by step,click here to check if the toolkit is installed correctly. Also,the post-installation-actions must be taken into consideration,click here to get more info.
I had occured the same condition u mention above, In my case, I add this path to the PATH:
$ export PATH=/usr/local/cuda-9.2/bin${PATH:+:${PATH}}
The best solution should be to modify the corresponding profile file, like this:
vim /etc/profile
Add export PATH=/usr/local/cuda-9.2/bin${PATH:+:${PATH}} to the end of the file
reboot
Good Luck.

Confusing cuda versions

I just installed the latest CUDA 9.1 on Ubuntu 16.04 according to the official instruction. But when I run the command nvcc -V, it still shows my cuda version is 7.5 like below.
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2015 NVIDIA Corporation
Built on Tue_Aug_11_14:27:32_CDT_2015
Cuda compilation tools, release 7.5, V7.5.17
Also, which nvcc gave me /usr/bin/nvcc which is not under /usr/local folder. Is this normal? Is this a compatibility issue? I have a GTX 1080 Ti and a GTX 980. I added commands below to .bashrc file, but it still didn't work.
export PATH=/usr/local/cuda-9.1/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-9.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
The best thing to do here is to remove all traces of CUDA binaries from the /usr/bin directory, and in the future always install the CUDA toolkit in the "default" locations at /usr/local/cuda-XX
To remove CUDA items from /usr/bin, just use the linux rm command as a root user. Not sure what to remove? Take a look in an "ordinary" CUDA install bin directory, such as /usr/local/cuda-8.0/bin
By having your CUDA install at the default locations e.g. /usr/local/cuda-8.0 and /usr/local/cuda-9.0 (for example), you can have "side-by-side" installs, and switch between them by modifying the PATH and LD_LIBRARY_PATH variables accordingly.

Updating a Cuda 4.0 project to Cuda 4.2

I have a VS2010 project that was tested with CUDA 4.0, today I installed CUDA 4.2 and I want to update this project, the problem is that when I try to run the project it asks me for cudart32_40_17.dll, but since this is CUDA 4.2 I only have on my folders (C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.2\bin) cudart32_42_9.dll. I already set the Build Customizations to Cuda 4.2 and it compiles without any problem, the only problem is when I try to run it, the app asks me for the previous version of the dll. Is there a way to especify that the project must use cudart32_42_9.dll?
There was another library in the project that was compiled using Cuda 4.0, so I have to recompile the library (OpenCV) with Cuda 4.2.
one way, you can use nvidia parallel nsight to change it.
another is reset cuda linker point to the CUDA4.2 ,compiler use 4.2 nvcc.
good luck

cutil.h CUT_SAFE_CALL in CUDA 4.0

I am using CUDA 4.0 . I am trying to use the following functions.
CUT_DEVICE_INIT();
CUT_SAFE_CALL(cutCreateTimer(&hTimer));
I included cutil.h to use the above functions. But the compiler reports the following..
fatal error C1083: Cannot open include file: 'cutil.h': No such file or directory
I searched in the CUDA directory but there is no file 'cutil.h'.
How can I find the time needed for a CUDA function using the above method? (not using the C++ timer)
You probably didn't tell your compiler where to find the file. I can't tell you exactly because you didn't provide details on what system you are using but for example, on Windows XP and assuming a default installation of version 4.0 of the SDK the cutil.h header file is in:
C:\Documents and Settings\All Users\Application Data\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.0\C\common\inc
For Windows 7 I think it is:
C:\Program Data\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.0\C\common\inc
but not sure.