How to install cuda on ubuntu?

Member

by tina , in category: Installation & Upgrades , 6 months ago

How to install cuda on ubuntu?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

Member

by emie , a month ago

@tina 

To install CUDA on Ubuntu, you will need to follow these steps:

  1. Verify that your system meets the requirements for CUDA. Your system must have a GPU that is compatible with CUDA and a 64-bit version of Ubuntu. You can check if your GPU is compatible with CUDA by visiting the NVIDIA website.
  2. Download the CUDA Toolkit installer from the NVIDIA website. The installer will be a .deb file, which you can download to your Ubuntu system.
  3. Open a terminal and navigate to the directory where you downloaded the installer.
  4. Install the CUDA Toolkit by running the following command:


sudo dpkg -i cuda-repo-ubuntu*_10.1.243-1_amd64.deb

  1. Update the package manager:


sudo apt-get update

  1. Install the CUDA drivers:


sudo apt-get install cuda

  1. Add the CUDA bin directory to your PATH environment variable:


export PATH=/usr/local/cuda/bin:$PATH

  1. Add the CUDA library directory to your LD_LIBRARY_PATH environment variable:


export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

  1. Test your installation by running the nvidia-smi command:


nvidia-smi


This command should display information about your GPU, including its model and the amount of memory it has. If the command runs successfully and you see this information, your CUDA installation is complete.


Note: These instructions are for CUDA 10.1. If you are using a different version of CUDA, you may need to modify the commands slightly. It is also a good idea to read the installation instructions in the CUDA documentation before proceeding.

by keegan.towne , a month ago

@tina 

To install CUDA on Ubuntu, you will need to follow these steps:

  1. Verify that your system has a CUDA-capable GPU. You can do this by running the following command:
1
lspci | grep -i nvidia


If the command returns any output, then your system has a CUDA-capable GPU.

  1. Check the version of your Ubuntu installation. CUDA is supported on Ubuntu 18.04 and later. You can check your Ubuntu version by running the following command:
1
lsb_release -a


  1. Install the NVIDIA graphics driver. You can do this by running the following command:
1
2
sudo apt-get update
sudo apt-get install nvidia-driver-<version>


Replace <version> with the version of the NVIDIA driver that is compatible with your GPU and Ubuntu version. You can find a list of supported driver versions on the NVIDIA website.

  1. Install the CUDA toolkit. You can do this by running the following command:
1
2
3
4
5
6
7
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu<version>/x86_64/cuda-ubuntu<version>.pin
sudo mv cuda-ubuntu<version>.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/11.1.1/local_installers/cuda-repo-ubuntu<version>_11.1.1-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu<version>_11.1.1-1_amd64.deb
sudo apt-key add /var/cuda-repo-<version>/7fa2af80.pub
sudo apt-get update
sudo apt-get -y install cuda


Replace <version> with the version of Ubuntu you are using (e.g., 18.04, 20.04, etc.).

  1. Update your PATH and LD_LIBRARY_PATH environment variables to include the CUDA installation directory. You can do this by adding the following lines to your .bashrc file:
1
2
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH


  1. Reboot your system to complete the installation.


After completing these steps, CUDA should be installed on your system and you should be able to use it to develop GPU-accelerated applications.