Problem while installing cuda toolkit in ubuntu 18.04

40,707

Solution 1

I just ran into this issue and solved it by running the following commands:

sudo apt clean
sudo apt update
sudo apt purge nvidia-* 
sudo apt autoremove
sudo apt install -y cuda

Major thanks to this post on the Nvidia forums.

Solution 2

I think the issue is the CUDA driver version. It looks like the installer tries to install the newest version 455.23.05 and the installation actually fails there.

I've solved it by first downloading the local installer and unselecting the CUDA driver installation, so it just installs the toolkit.

wget https://developer.download.nvidia.com/compute/cuda/11.1.0/local_installers/cuda_11.1.0_455.23.05_linux.run
chmod +x cuda_11.1.0_455.23.05_linux.run 
sudo ./cuda_11.1.0_455.23.05_linux.run 

In the menu unselect the driver installation: enter image description here If not already done, add the nvidia repo as per instructions from the official website before installing the driver:

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /"
sudo apt-get update

Install the CUDA driver 450 manually:

sudo apt-get install cuda-drivers-450

Test by running nvcc -V In case nvcc is not found, don't forget to add it to your PATH: PATH=$PATH:/usr/local/cuda/bin

Solution 3

You have to uninstall any nvidia driver before running sudo apt install -y cuda
To do so, got to "Software & Updates" -> "Additional drivers" -> Using X.Org X (nouveou)

Share:
40,707

Related videos on Youtube

Taha Sherif
Author by

Taha Sherif

Updated on September 18, 2022

Comments

  • Taha Sherif
    Taha Sherif over 1 year

    After following all the instructions in CUDA Toolkit 11.1 Downloads, the last instruction

    sudo apt-get -y install cuda
    

    doesn't work for me.

    Terminal shows this message:

    The following packages have unmet dependencies:
     cuda : Depends: cuda-11-1 (>= 11.1.0) but it is not going to be installed
    E: Unable to correct problems, you have held broken packages.
    

    PS: I have an NVIDIA GTX 1660TI card in my computer.

    Any solution please?

    • karel
      karel over 3 years
    • ubfan1
      ubfan1 over 3 years
      Does anything not work after your dpkg -i install, which should have supplied all necessary files? Might have been a cut and paste error on Nvidia's part from their debnetwork install.
    • rob
      rob about 3 years
      same issue with Cuda 11.3 on Ubuntu 20.04
  • Taha Sherif
    Taha Sherif over 3 years
    I just added the "PATH=$PATH:/usr/local/cuda/bin" in my path and it works well now ! Thank you !
  • Update
    Update over 3 years
    Actually works.
  • Mian Asbat Ahmad
    Mian Asbat Ahmad about 3 years
    Worked like a charm and yes you need setting PATH like Taha mentioned.
  • rob
    rob about 3 years
    solved it for same issue for cuda 11.3 on Ubuntu 20.04
  • kanehekili
    kanehekili almost 3 years
    The OP asked about 18.04, will your solution work for this version ?
  • user1045680
    user1045680 almost 3 years
    Matt, the post you referenced had apt purge cuda after apt update. Any reason you didn't use that step from the post you referenced?
  • Matt Popovich
    Matt Popovich almost 3 years
    @user1045680 Good question and good point. I normally try to do the least destructive thing possible when debugging things. If it fails, I then try again with more destruction! So I think I first ran it without apt purge cuda to see what would happen... it ended up working, and I posted it! Adding apt purge cuda would be a good second attempt if the above list of commands fails.
  • Matt Popovich
    Matt Popovich almost 3 years
    Seems to be a duplicate solution of my answer... I know you don't have enough reputation to leave comments, but this probably would have been best as a comment "can confirm this works on Ubuntu 20.04 with Nvidia Quadro P520". Glad it worked for you!
  • Anthony Nash
    Anthony Nash over 2 years
    This really helped. The posts above (and below) talk of purging the machine of Cuda related material. Sadly, that didn't resolve the issue, but this approach did.