Skip to content

Instantly share code, notes, and snippets.

@tntim96
Last active March 15, 2019 00:00
Show Gist options
  • Save tntim96/2b1e26ed6700b342aa62c051b1353fa3 to your computer and use it in GitHub Desktop.
Save tntim96/2b1e26ed6700b342aa62c051b1353fa3 to your computer and use it in GitHub Desktop.

AI Setup

NVIDIA CUDA on Linux

The instructions below are for Debian. I run LMDE3 with Cinnamon, and I found using the latest CUDA and NVIDIA drivers broke Cinnamon, causing it to run in fall-back mode. This is still not working - the roll-back steps are given below.

  1. Check that you've got an NVIDIA device lspci | grep -i nvidia
  2. Verify your device supports CUDA
  3. Ensure your drivers are loaded - if not run sudo apt-get install nvidia-driver nvidia-smi
  4. Determine your driver version using nvidia-smi (in my case 390.87)
  5. Find which version of CUDA is supported by your driver from stack-overflow or official link (in my case it is CUDA 9.1) - table duplicated below
  6. Go to https://developer.nvidia.com/cuda-toolkit-archive
    1. Choose your CUDA version
    2. Choose Linux
    3. Choose x86_64
    4. Choose Ubuntu
    5. Choose 17.04
    6. Choose runfile
    7. Download the base installer
  7. Login as root sudo su -
  8. Create/edit /etc/modprobe.d/blacklist-nouveau.conf to include
blacklist nouveau
options nouveau modeset=0
  1. Run the installer sh /home/user/Downloads/cuda_9.1.85_387.26_linux.run
    1. Install everything except the driver and the samples
    2. Exit root user
  2. Install the samples for you normal user: /usr/local/cuda/bin/cuda-install-samples-9.1.sh ~/dev/
  3. Compile the samples:
    1. cd ~/dev/NVIDIA_CUDA-9.1_Samples
    2. make
  4. Run a sample
./0_Simple/matrixMul/matrixMul                   
[Matrix Multiply Using CUDA] - Starting...
GPU Device 0: "GeForce GTX 950M" with compute capability 5.0

MatrixA(320,320), MatrixB(640,320)
Computing result using CUDA Kernel...
done
Performance= 179.84 GFlop/s, Time= 0.729 msec, Size= 131072000 Ops, WorkgroupSize= 1024 threads/block
Checking computed result for correctness: Result = PASS

NOTE: The CUDA Samples are not meant for performance measurements. Results may vary when GPU Boost is enabled.
CUDA 10.0: 410.48
CUDA    9.2: 396.xx
CUDA    9.1: 390.xx (update)
CUDA    9.0: 384.xx
CUDA    8.0    375.xx (GA2)
CUDA    8.0: 367.4x
CUDA    7.5: 352.xx
CUDA    7.0: 346.xx
CUDA    6.5: 340.xx
CUDA    6.0: 331.xx
CUDA    5.5: 319.xx
CUDA    5.0: 304.xx
CUDA    4.2: 295.41
CUDA    4.1: 285.05.33
CUDA    4.0: 270.41.19
CUDA    3.2: 260.19.26
CUDA    3.1: 256.40
CUDA    3.0: 195.36.15

Roll-back

  1. Remove nvidia drivers sudo apt-get purge nvidia*
  2. Comment out entires in /etc/modprobe.d/blacklist-nouveau.conf
  3. Regenerate an initramfs image sudo update-initramfs -u
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment