How to install nvidia graphics card drivers for machine learning
I have no idea how many times I have needed to do this, but I am making this page to help everyone else who is confused by Nvidia’s seemingly infinite options for installing graphics drivers. This will get you the CUDA Toolkit, cuDNN, and Graphics Drivers for Nvidia GPUs. You can go further with my guides on how to install TensorFlow and PyTorch(links in progress).
INSTALL CUDA toolkit
Yes, you read this right. According to the official Nvidia documentation, you first install the Cuda toolkit as a base install, and then the graphics driver.
First, browse to this website and follow the drop downs for your implementation of Cuda Toolkit:
https://developer.nvidia.com/cuda-downloads?
A list of installation instructions will pop up. You should follow these instructions and copy and paste them one at a time into your terminal.
INSTALL cuDNN
You may also need CUDNN, and is recommended for installation:
https://developer.nvidia.com/cuda-downloads?
A list of installation instructions will pop up. You should follow these instructions and copy and paste them one at a time into your terminal.
INSTALL GPU DRIVER
First, make sure to update your system using the command:
sudo apt-get update -y
You need to install and manage the GPU drivers 1 of 3 ways:
(Recommended)(Ubuntu Linux Only) Install via CLI
Install via source download
Install using GeForce Experience (Windows Only)(Not Recommended)
You can find all three options below. Again, note that while option 1 is recommended, it is likely only supported with Ubuntu distributions.
OPTION 1: CLI
Option 1 is installing via the CLI and is the recommended, most straightforward way to perform this operation. However, this method uses an ubuntu specific command, so it may be worth going to Option 2: source installation if you are using something other than Ubuntu.
Update
Make sure to always update your env using the following command:
sudo apt-get update -y
Install Ubuntu Drivers Utility
Ubuntu provides a handy utility function for installing drivers via the command:
sudo apt-get install ubuntu-drivers-common
INSTALL RECOMMENDED DRIVER
Run the following command and find the recommended driver:
ubuntu-drivers devices
You can install any of the following drivers, but I usually choose the recommended driver for whichever GPU is installed. The example GPU is an Nvidia Tesla v100. You can install the GPU driver with a command similar to the following:
sudo apt-get install nvidia-driver-XXX
Then, reboot your machine using:
sudo reboot
Finally, check to see if the drivers installed properly using the command:
nvidia-smi
If the above table prints out(versions of CUDA and driver will vary with time and card), then you have successfully installed the CUDA GPU Drivers.
Option 2: source
The next option works for most systems, in case you are not using Ubuntu. However, their can be some weird package dependency issues depending on the system.
Follow the nvidia dropdown menu
Follow the link below, and select your operating system.
https://www.nvidia.com/download/index.aspx
Once downloaded, you can run the following runfile or executable as your operating system sees fit.
Option 3: GeForce expirence
This last option is a weird hybrid option in the case that you are using WSL for Windows. You may have to automatically install drivers directly on the Windows side using the standard GeForce experience manager, and then install via option 1/2 above. Please note this is for Windows machines only.
Download geforce expirence
Follow the link below to download and install GeForce Expirence.
https://www.nvidia.com/en-us/geforce/geforce-experience/
Once downloaded, you can run the following runfile or executable as your operating system sees fit.
Follow the nvidia dropdown menu
Follow the link below, and select your operating system. It may be WSL.
https://www.nvidia.com/download/index.aspx
Once downloaded, you can run the following runfile or executable as your operating system sees fit.