4

I am using Conda on Ubuntu 16.04. My objective is to associate each Conda environment to a specific version of CUDA / cuDNN. I had a look around and I found this interesting article, which basically suggests to put different CUDA versions into different folders and then use an environment-specific bash script (run when the environment is activated) to properly set the PATH/LD_LIBRARY_PATH variables (which creates the association with the CUDA version). This is fine, but when I try to install frameworks such as pytorch using Conda, it forces me to install also the "cudatoolkit" package. So, a couple of questions:

1) does downloading cudatoolkit mess up my previous CUDA configurations? which version will be used?

2) if using Conda is possible to install "cudatoolkit" and also "cudnn", why not just using conda for everything? Why even needing to apply the instructions of the above mentioned article?

Thank you.

Max
  • 41
  • 1
  • 2

1 Answers1

3

As an answer to the first question, no, downloading and installing another CUDA toolkit won't mess up other configurations. From CUDA toolkit installer, you specify an installation directory, so just pick whatever works for you that is unique to that CUDA version. This won't affect any currently installed CUDA versions. A Pytorch install will look for a CUDA_HOME environment variable as well as in '/usr/local/cuda' (the default CUDA toolkit install dir.), so it's just this environment variable that needs to be changed.

I can't speak for the second part. Perhaps the installation using Conda will use the default installation directory for the CUDA toolkit (seems silly but this is just speculation).

  • Ok the CUDA toolkit installer won't affect any currently installed CUDA version, but what about the Conda 'toolkit' package? What happens when it is installed using Conda? Where is it installed? Does it setany environment variable? – Max Mar 26 '19 at 08:03
  • I meant Conda 'cudatoolkit' – Max Mar 26 '19 at 08:16
  • From a brief test, it looks like using conda for that will indeed overwrite the previous toolkit version when you install a new one. [Here](https://imgur.com/a/ttJOJd1) I install the CUDA 8.0 toolkit with conda, and then run the installer afterwards with 9.0 [here](https://imgur.com/a/ILXF44s). Note it says the package will be updated. Running "numba -s" confirms there is only 1 CUDA toolkit version as well. Hope this helps! There may be a way to have unique versions through Conda, but it is definitely not the default. –  Mar 26 '19 at 14:58
  • Just to be sure, with "installer" you mean the runfile that you can download from the NVIDIA website? – Max Mar 28 '19 at 17:13
  • Yeah, that run file will guide you through the install, and prompt you for things like a directory for the toolkit, for the samples (if you want them), etc. –  Mar 28 '19 at 17:16
  • Did you notice what is the cuda installation directory when you use install "cudatoolkit" using Conda? And which environment variables does it automatically set? – Max Mar 29 '19 at 12:28
  • It will put libcudart.so in the "Somewhere in your system"/anaconda3/lib/ directory, and will also be in the packages "Somewhere in your system"/anaconda3/pkgs/cudatoolkit-"Some version"/lib/ directory. Looking at my own, it appears I was right to think that overwriting a CUDA install would be silly, and I can see the CUDA 8 toolkit in another of the pkgs directories. Since you can't have two libcudart.so in the same directory, it just throws whatever is the latest you downloaded in the anaconda3/lib directory. –  Mar 29 '19 at 14:53
  • Downgrading your CUDA version also does not remove the CUDA toolkit from the pkgs directory either (e.g. if you do conda install on a lower version of CUDA). –  Mar 29 '19 at 14:55