Installing multiple CUDA Libraries in the same machine
If you are in a situation where you need to use multiple CUDA libraries in the same machine because maybe you are experimenting with some codes which require different CUDA versions then don’t worry there is a trick to have multiple CUDA libraries installed in the same machine.
Note: Below I will be showing how to configure
CUDA 10.0
andCUDA 9.0
inUbuntu 18.04
but the mentioned method should work for any CUDA version and it should also work for more than 2 CUDA libraries.
Step 1: Install CUDA libraries by following this post. Don’t worry about file overwriting because both CUDA libraries will be installed at different paths. CUDA 9.0
will be installed at /usr/local/cuda-9.0
path and CUDA 10.0
will be installed at /usr/local/cuda-10.0
path. The only thing which will be overwritten is the Symbolic link and I will show later how to fix that.
Note: You can install libraries in any order.
Step 2: Remove Symbolic link.
$ cd /usr/local
$ sudo rm cuda
Update Symbolic link.
# If switching to CUDA 10.0
$ sudo ln -s cuda-10.0 cuda
or
# If switching to CUDA 9.0
$ sudo ln -s cuda-9.0 cuda
Step 3: Update CUDA path in ~/.bashrc
file.
- If switching to
CUDA 10.0
then commentCUDA 9.0
path and uncommentCUDA 10.0
path. - If switching to
CUDA 9.0
then commentCUDA 10.0
path and uncommentCUDA 9.0
path.
Step 4: Reload bashrc file.
$ source ~/.bashrc
Step 5: Check current CUDA version.
$ nvcc --version
Thank you for taking the time to read this article! I hope it offered some valuable insights. If you found it helpful, feel free to clap, share it with others, or support my work with a coffee!
If you have any questions or thoughts, feel free to leave a comment. You can follow me on Medium, LinkedIn, GitHub or contact me at atinesh.s@gmail.com.