How To Install CUDA 9.2 in Ubuntu

  1. Download CUDA 9.2
    1. Use this website
    2. 17.04 version still works
  2. Install latest NVIDIA graphics drivers
    1. Do NOT use the Nvidia website’s .run file. It will crash
    2. Run the command
      sudo add-apt-repository ppa:graphics-drivers/ppa
      to add the repository
    3. Go into the software center → Software & Updates → Additional Drivers
    4. Select “Using NVIDIA driver metapackage from nvidia-driver-396” and apply changes
      • 396 is the latest, short-term release driver. You have to use the latest short-term release driver instead of the latest long-term release driver for CUDA
    5. Eventually it will prompt you with a EULA and a secureboot password. Remember this password. It will only be used once, and there is a probably a long process if you accidentally type it in wrong
    6. Reboot your computer
    7. A blue screen will appear before the boot sequence. Hit Enroll → Continue, enter in the previously mentioned password, and reboot.
  3. Verify that the drivers work by running
    nvidia-smi
    . It should look like this
    • nvidia-smi
  4. Install CUDA “dependencies” with
    sudo apt-get install freeglut3 freeglut3-dev libxi-dev libxmu-dev
  5. Install CUDA 9.2
    1. Navigate to where you installed the CUDA downloads
    2. Run the command sudo sh cuda_9.2.148_396.37_linux.run
    3. Read the EULA and other information
    4. Answer the questions this way:
      
      You are attempting to install on an unsupported configuration. Do you wish to continue?
      (y)es/(n)o [ default is no ]: y	
      *IMPORTANT*
      Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 396.26?
      (y)es/(n)o/(q)uit: n
      
      Install the CUDA 9.2 Toolkit?
      (y)es/(n)o/(q)uit: y
      			
      Enter Toolkit Location
          [ default is /usr/local/cuda-9.2 ]:
      			
      Do you want to install a symbolic link at /usr/local/cuda?
      (y)es/(n)o/(q)uit: y
      			
      Install the CUDA 9.2 Samples?
      (y)es/(n)o/(q)uit: y
      			
      Enter CUDA Samples Location
          [ default is /home/cindy ]: (optional, keep it in ~)
          
    5. Install the patch with
      sudo sh cuda_9.2.148.1_linux.run
    6. Setup the PATH and LD_LIBRARY_PATH environments with
      export PATH=/usr/local/cuda-9.2/bin${PATH:+:${PATH}}
      export LD_LIBRARY_PATH=/usr/local/cuda-9.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
      • NOTE: the above command only works for the current session. To make these commands run after a shutdown, edit ~/.bashrc and add the two lines to the bottom of that file
  6. Test CUDA by building the samples
    cd ~
    mkdir cuda-testing
    cp a NVIDIA_CUDA-9.2_Samples cuda-testing
    cd cuda-testing
    make -j4
  7. Run samples
    cd bin/x86_64/linux/release
    ./simplePrintf
    and run any others you’d like!

Credit goes to Dr. Donald Kinghorn with this article