Skip to content

Installing CUDA [English]

Lewis edited this page Jun 12, 2024 · 1 revision

IMPORTANT: Zed installer requires CUDA 9.1, while TensorFlow requires CUDA 9.0. The tutorial assumes CUDA 9.0 will be installed. In Ubuntu 18.04, install CUDA 10.0: https://github.com/LCAD-UFES/carmen_lcad/wiki/Instaling-CUDA-10.

There are several ways to install the CUDA Toolkit. Unfortunately, there isn't a definitive method; if one doesn't work, try another.

Installation Method 1

The simplest way to install CUDA is by using the .deb package, which will install both the Driver and the CUDA Toolkit. This method should work in most situations, especially on older computers. If this method fails, follow the procedure below: Download the appropriate CUDA 9.0 .deb file for your system and follow the installation steps on the site:

CUDA TOOLKIT 9.0 Ubuntu 16.04 64bits

Installation Instructions:
`sudo dpkg -i cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64.deb`
`sudo apt-key add /var/cuda-repo-<version>/7fa2af80.pub`
`sudo apt-get update`
`sudo apt-get install cuda`

Also, install the patches indicated on the page.

Skip to the Test Installation section and follow it to the end.

Installation Method 2

Install the Graphics Card Driver from the Manufacturer

In System Settings, go to Software & Updates.

Go to the Additional Drivers tab, select the first NVIDIA driver option, and click Apply Changes. Wait for the process to complete. Once the option to restart the computer appears, restart it.

Software & Updates Image

Install CUDA 9.0

Access the link below: CUDA 9.0 download runfile

Download the Base Installer and, with the terminal open in the Downloads folder, type the command:

sudo sh cuda_9.0.176_384.81_linux.run

Press space to scroll through the terms and agreements and respond to the following questions as shown below:

Do you accept the previously read EULA?
accept/decline/quit: accept

Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81?
(y)es/(n)o/(q)uit: n

Install the CUDA 9.0 Toolkit?
(y)es/(n)o/(q)uit: y

Enter Toolkit Location
 [ default is /usr/local/cuda-9.0 ]: 

Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: y

Install the CUDA 9.0 Samples?
(y)es/(n)o/(q)uit: n

Again on the CUDA 9.0 download page, download and install the existing patches one by one, similar to the base installation:

  • Command sudo sh <filename>
  • Scroll through the terms by pressing space
  • Type accept at the end

Test Installation

To test if the installation was successful, compile and run two provided examples:

cd /usr/local/cuda-9.0/samples/1_Utilities/deviceQuery
sudo make
./deviceQuery
cd /usr/local/cuda-9.0/samples/5_Simulations/particles
sudo make
./particles

Install CuDNN

Go to NVIDIA CuDNN and click on Download CuDNN. On the next page, create an account or log in if you already have one.

On the CuDNN Download page, check the box I Agree To the Terms of the cuDNN Software License Agreement and at the bottom of the page, click on Archived cuDNN releases. Click on Download cuDNN v7.4.1 (Nov 8, 2018), for CUDA 9.0 and download the following files:

  • cuDNN Runtime Library for Ubuntu16.04 (Deb)
  • cuDNN Developer Library for Ubuntu16.04 (Deb)
  • cuDNN Code Samples and User Guide for Ubuntu16.04 (Deb)

Open the terminal in the downloads folder and install the three packages:

cd ~/Downloads
sudo dpkg -i libcudnn7_7.4.2.24-1+cuda9.0_amd64.deb
sudo dpkg -i libcudnn7-dev_7.4.2.24-1+cuda9.0_amd64.deb
sudo dpkg -i libcudnn7-doc_7.4.2.24-1+cuda9.0_amd64.deb

To test:

cp -r /usr/src/cudnn_samples_v7/ $HOME
cd  $HOME/cudnn_samples_v7/mnistCUDNN
make clean && make
./mnistCUDNN

If the following error occurs:

error while loading shared libraries: libcudart.so.9.0: cannot open shared object file: No such file or directory
Run:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64

Install Other Dependencies

sudo apt-get install libcupti-dev
echo 'export LD_LIBRARY_PATH=/usr/local/cuda/extras/CUPTI/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc

If you haven't already installed the Oracle Java JDK:
sudo apt-get install openjdk-8-jdk

wget https://github.com/bazelbuild/bazel/releases/download/0.11.1/bazel_0.11.1-linux-x86_64.deb
sudo dpkg -i bazel_0.11.1-linux-x86_64.deb
Clone this wiki locally