How do I Install CUDA on Ubuntu 18.04?

In a terminal, type:


sudo add-apt-repository ppa:graphics-drivers/ppa

sudo apt update

sudo ubuntu-drivers autoinstall

reboot


sudo apt install nvidia-cuda-toolkit gcc-6

nvcc --version

I have a gtx970 graphics card and a fresh install of Ubuntu 18.04

This worked for me


I have installed CUDA 9.1 on Ubuntu 18.04, and runs very well.

I modify THE default gcc and g++, and use .run files instead of .deb files.

  1. Install gcc-6, g++-6 (CUDA requires gcc-6 !)

  2. In /usr/bin run

    sudo rm gcc, gcc-ar, gcc-nm, gcc-ranlib g++ 
    sudo ln -s gcc-6 gcc 
    sudo ln -s gcc-ar-6 gcc-ar 
    sudo ln -s gcc-nm-6 gcc-nm 
    sudo ln -s gcc-ranlib-6 gcc-ranlib 
    sudo ln -s g++-6 g++
    
  3. Install CUDA using .run files. Installing the latest driver (if required, download NVIDIA-Linux-xxxxxxx.run from Nvidia) would be better.

That's all.

I've tried to install using .deb files, but it causes package conflicts so I've switched to using this way.

Enjoy it!!


Enable multiverse repository, install nvidia drivers and nvidia-cuda-toolkit and gcc6 (preferably using update-alternatives to easily switch versions):

  1. In software & updates, select the restricted and multiverse repositories
  2. In the Additional Drivers tab in software & updates select the NVIDIA proprietary driver (390 for CUDA 9)
  3. sudo apt update && sudo apt install nvidia-cuda-toolkit, or install it from the ubuntu software center.
  4. CUDA requires gcc6, use update-alternatives to maintain both gcc7 and gcc6 as explained here.

Alternatively you can follow Taylor's instructions:

  1. After installing the proprietary NVIDIA driver, download CUDA 9 installation from their site (get Ubuntu the 17.04 runfile version)
  2. make the downloaded file executable with sudo chmod +x
  3. run it with --override flag
  4. Accept the terms and conditions, say yes to installing with an unsupported configuration, and no to “Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81?”. Make sure you don’t agree to install the new driver.
  5. See above about using gcc6

The second method has the downside that it's not as easy to upgrade or remove.

Tags:

Cuda

Nvidia

18.04