Table of Content
This guide covers the basic instructions needed to install CUDA and verify that a CUDA application can run on Linux.
CUDA on Linux can be installed using an RPM, Debian, Runfile, or Conda package, depending on the platform being installed on.
Installing CUDA Toolkit on Ubuntu
When installing CUDA on Ubuntu, you can choose between the Runfile Installer and the Debian Installer. The Runfile Installer is only available as a Local Installer. The Debian Installer is available as both a Local Installer and a Network Installer. The Network Installer allows you to download only the files you need. The Local Installer is a stand-alone installer with a large initial download. In the case of the Debian installers, the instructions for the Local and Network variants are the same. For more details, refer to the Linux Installation Guide.
Pre-installation Actions
Some actions must be taken before the CUDA Toolkit and Driver can be installed on Linux:
- Verify the system has a CUDA-capable GPU.
- Verify the system is running a supported version of Linux.
- Verify the system has
gcc
installed. - Verify the system has the correct kernel headers and development packages installed.
- Download the NVIDIA CUDA Toolkit.
- Handle conflicting installation methods.
Verify the system has a CUDA-capable GPU
To verify that your GPU is CUDA-capable, go to your distribution’s equivalent of System Properties, or, from the command line, run:
|
|
It must return your detected Graphic Card
|
|
Verify the system is running a supported version of Linux
The CUDA Development Tools are only supported on some specific distributions of Linux. These are listed in the CUDA Toolkit release notes.
To determine which distribution and release number you’re running, type the following at the command line:
|
|
You should see output similar to the following, modified for your particular system:
|
|
Verify the system has gcc
installed
The gcc
compiler is required for development using the CUDA Toolkit. It is not required for running CUDA applications. It is generally installed as part of the Linux installation, and in most cases the version of gcc
installed with a supported version of Linux will work correctly.
To verify the version of gcc
installed on your system, type the following on the command line:
|
|
|
|
Verify the system has the correct kernel headers and development packages installed
The kernel headers and development packages for the currently running kernel can be installed with:
|
|
Download the NVIDIA CUDA Toolkit
The NVIDIA CUDA Toolkit is available at https://developer.nvidia.com/cuda-downloads.
Handle conflicting installation methods.
Before installing CUDA, any previously installations that could conflict should be uninstalled. This will not affect systems which have not had CUDA installed previously, or systems where the installation method has been preserved
Using Debian installer
Basically, the steps to install using this method are. Install the repository meta-data, install GPG key, update the apt-get cache, and install CUDA.
Note that is
sudo
is installed on your system, you need to execute following commands withsudo
and the current user must be insudoers
.
|
|
Now you to reboot the machine and setup your environment.
|
|
Finally, if you want the samples you can get them with
|
|
Remember that you have to run the samples by navigating to the executable’s location, otherwise it will fail to locate dependent resources.
Using runfile installer
DISABLE Nouveau drivers
Create a file at /etc/modprobe.d/blacklist-nouveau.conf
with the following contents
|
|
Regenerate the kernel initramfs
|
|
After this step, reboot into runlevel 3 by temporarily adding the number 3
and the word nomodeset
to the end of the system’s kernel boot parameters. Finally, run the installer:
|
|
Create an xorg.conf
file to use the NVIDIA GPU for display:
|
|
CUDA Toolkit Post-installation steps
The post-installation actions must be manually performed. These actions are split into mandatory, recommended, and optional sections.
- Environment Setup
- Install Persistence Daemon
Install Persistence Daemon
NVIDIA is providing a user-space daemon on Linux to support persistence of driver state across CUDA job runs. The daemon approach provides a more elegant and robust solution to this problem than persistence mode. For more details on the NVIDIA Persistence Daemon.
The NVIDIA Persistence Daemon can be started as the root user by running
|
|
References
- https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html
- https://docs.nvidia.com/cuda/pdf/CUDA_Installation_Guide_Linux.pdf
Subscribe, donate or become premium
💬 Share this post in social media
Thanks for checking this out and I hope you found the info useful! If you have any questions, don't hesitate to write me a comment below. And remember that if you like to see more content on, just let me know it and share this post with your colleges, co-workers, FFF, etc.