Trying to install CUDA, but getting errors

Solution 1:

You need to download the drivers first. Try first running this

sudo apt install libnvidia-tesla-cuda1 libnvidia-tesla-cuda1-i386

then running your install command when Apt is finished with this one.

This is the description from apt search :

NVIDIA CUDA Driver Library (Tesla version)

EDIT

After doing more research on the question, I found the official documentation which includes installation instructions. As it turns out, there is a bit more to the process:

Perform the pre-installation actions.

Install repository meta-data

    $ sudo dpkg -i cuda-repo-<distro>_<version>_<architecture>.deb

Install the CUDA public GPG key

When installing using the local repo:

    $ sudo apt-key add /var/cuda-repo-<distro>-<version>/7fa2af80.pub

When installing using network repo on Ubuntu 20.04/18.04:

    $ sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/<distro>/<architecture>/7fa2af80.pub

When installing using network repo on Ubuntu 16.04:

    $ sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/<distro>/<architecture>/7fa2af80.pub

Pin file to prioritize CUDA repository:

    $ wget https://developer.download.nvidia.com/compute/cuda/repos/<distro>/<architecture>/cuda-<distro>.pin
    $ sudo mv cuda-<distro>.pin /etc/apt/preferences.d/cuda-repository-pin-600

Update the Apt repository cache

    $ sudo apt-get update

Install CUDA Note: These two commands must be executed separately.

    $ sudo apt-get install cuda

To include all GDS packages:

    $ sudo apt-get install nvidia-gds 

Perform the post-installation actions.

SOURCES

Official Installation Guide

Section on Apt based install on Ubuntu