Skip to content

Instantly share code, notes, and snippets.

@eddex
Last active November 22, 2023 16:12
Show Gist options
  • Star 23 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save eddex/707f9cbadfaec9d419a5dfbcc2042611 to your computer and use it in GitHub Desktop.
Save eddex/707f9cbadfaec9d419a5dfbcc2042611 to your computer and use it in GitHub Desktop.
How to install CUDA 10.1 on Ubuntu 18.04

How to install CUDA 10.1 on Ubuntu 18.04

A clean installation of Ubuntu 18.04.02 LTS was used.

This gist is an extension to the official docs, adding missing parts and instructions.

2 pre-install actions

follow the pre-installation actions on: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#pre-installation-actions

step 2.3 - install gcc

install gcc: $ sudo apt-get install build-essential

step 2.5 - choose installation method

we'll be using the distribution-specific packages (deb)

step 2.6 - download NVIDIA CUDA Toolkit

choose Linux > x86_64 > Ubuntu > 18.04 > deb (local)

verification

the link in the official docs redirect to md5 hashes of CUDA 9.2 files

use this link instead: https://developer.download.nvidia.com/compute/cuda/10.1/Prod/docs/sidebar/md5sum.txt

3 package manager installation

follow the instructions in the next section https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#ubuntu-installation

you'll run into the following error:

$ sudo apt-get install cuda
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 cuda : Depends: cuda-10-1 (>= 10.1.105) but it is not going to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.

to fix this, update your NVIDIA drivers to nvidia-418

use the following tutorial and use the method using PPA repository to install Nvidia Beta drivers: https://linuxconfig.org/how-to-install-the-nvidia-drivers-on-ubuntu-18-04-bionic-beaver-linux

summary:

$ sudo add-apt-repository ppa:graphics-drivers/ppa
$ sudo apt update
$ ubuntu-drivers devices
== /sys/devices/pci0000:00/0000:00:01.1/0000:02:00.0 ==
modalias : pci:v000010DEd00001004sv00001458sd00003604bc03sc00i00
vendor   : NVIDIA Corporation
model    : GK110 [GeForce GTX 780]
driver   : nvidia-driver-410 - third-party free
driver   : nvidia-driver-396 - third-party free
driver   : nvidia-driver-415 - third-party free
driver   : nvidia-driver-390 - distro non-free
driver   : nvidia-340 - distro non-free
driver   : nvidia-driver-418 - third-party free recommended
driver   : xserver-xorg-video-nouveau - distro free builtin

nvidia-driver-418 is recommended, therefore execute:

$ sudo ubuntu-drivers autoinstall

after that $ sudo apt-get install cuda will work

7 post-installation actions

follow the post-installation steps: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#post-installation-actions

7.1.1

add the following line to the end of ~/.bashrc

export PATH="/usr/local/cuda-10.1/bin:/usr/local/cuda-10.1/NsightCompute-2019.1:$PATH"

done

@nicolas-gervais
Copy link

nicolas-gervais commented Apr 10, 2020

This line wasn't useful for me:

export PATH="/usr/local/cuda-10.1/bin:/usr/local/cuda-10.1/NsightCompute-2019.1:$PATH"

Because the installation process named the folder /usr/local/cuda and not cuda-10-1. Could you maybe advise? Feel free to explain it to me like I'm 5.

@eddex
Copy link
Author

eddex commented Apr 10, 2020

This line wasn't useful for me:

export PATH="/usr/local/cuda-10.1/bin:/usr/local/cuda-10.1/NsightCompute-2019.1:$PATH"

Because the installation process named the folder /usr/local/cuda and not cuda-10-1. Could you maybe advise? Feel free to explain it to me like I'm 5.

@nicolas-gervais Maybe there is a new version of cuda which is installed in a different location. With apt-get install cuda you're installing the latest version.

To install a specific version, you can folow the steps described here: https://linoxide.com/linux-command/install-specific-version-package-apt-get/
It sould be something along the lines of apt-get install cuda=10.1 (but I haven't tested this).

Otherwise you can just change the path to your installation path. Something like this:

export PATH="/usr/local/cuda/bin:/usr/local/cuda/NsightCompute-2019.1:$PATH"

@oriolfornes
Copy link

oriolfornes commented May 29, 2020

This is a great gist. You have my star. It also works for CUDA 10.2.

When verifying the installation, execute make with --keep-going.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment