Skip to content

Instantly share code, notes, and snippets.

@iamkissg
Last active May 30, 2019 13:35
Show Gist options
  • Save iamkissg/3f957bb024fff5a9b38bedf0dc573f20 to your computer and use it in GitHub Desktop.
Save iamkissg/3f957bb024fff5a9b38bedf0dc573f20 to your computer and use it in GitHub Desktop.
Multiple CUDA Single Machine

How to maintain multiple CUDA versions in a single computer

Suppose we have already installed Nvidia GPU driver which should be equal to or newer than the required.

  1. Download cuda runfile (installer type: runfile (local)) from https://developer.nvidia.com/cuda-downloads
  2. Extract what we want: toolkit following the interactive prompt or sudo sh cuda-10.1.run --silent --toolkit --toolkitpath=/usr/local/cuda-10.1
    • To maintain a cudatoolkit with different versions of cudnn, we can name the dicrectory cuda-10.1_cudnn-v7.5
  3. Check the installation status
    • If /usr/local/cuda-10.1_cudnn-v7.5 contains only bin and pkgconfig, the installation failed. InstallUtils.pm is needed.
      1. ./cuda_8.0.61_375.26_linux.run --tar mxvf to extract InstallUtils.pm
      2. sudo cp InstallUtils.pm /usr/lib/x86_64-linux-gnu/perl-base/ (ubuntu)
      3. export $PERL5LIB
      4. sudo sh cuda-10.1.run --silent --toolkit --toolkitpath=/usr/local/cuda-10.1_cudnn_v7.5
      5. sudo rm /usr/lib/x86_64-linux-gnu/perl-base/InstallUtils.pm
  4. Remove or recreate /usr/local/cuda, which is the default cuda path
  5. Extract cuDNN file: tar -xzvf cudnn-10.1-linux-x64-v7.5.tgz
    • sudo cp ~/Gode/cudnn-10.1-linux-x64-v7.5/include/cudnn.h /usr/local/cuda-10.1_cudnn_v7.5/include
    • sudo cp ~/Gode/cudnn-10.1-linux-x64-v7.5/lib64/libcudnn* /usr/local/cuda-10.1_cudnn_v7.5/lib64
    • sudo chmod a+r /usr/local/cuda-10.1_cudnn_v7.5/lib64/libcudnn*
  6. Manually set environment variables for different virtual environments
    • export PATH=/usr/local/cuda-10.1_cudnn_v7.5/bin:$PATH
    • export LD_LIBRARY_PATH=/usr/local/cuda-10.1_cudnn_v7.5/lib64:$LD_LIBRARY_PATH
  7. Or follow this blog, update conda's activate and deactivate command.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment