Package dependency problem while installing CUDA on Ubuntu 14.04

I tried to follow the instructions on this link to install CUDA on Ubuntu 14.04, but on this step I got package dependency problem:

~/Downloads$ sudo apt-get install cudaReading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 cuda : Depends: cuda-7-0 (= 7.0-28) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Does someone know what could be the problem?


Solution 1:

Option 1: apt-get

  1. Install unmet dependencies

    sudo apt-get install cuda-runtime-7-0
    ...
    <more unmet dependencies>
    ....
    sudo apt-get install cuda-7-0
    
  2. Install main package

    sudo apt-get install cuda
    

Option 2: aptitude

  1. Install aptitude

    sudo apt-get install aptitude
    
  2. Install main package

    sudo aptitude install cuda
    

Solution 2:

It seems that you have installed certain nvidia drivers or deficient cuda toolkit previously, like some contradictory versions from the ubuntu's repository, so you should remove them firstly.

sudo apt-get purge nvidia-*
sudo apt-get autoremove

and then install cuda.

sudo apt-get install cuda

Solution 3:

This happened to me when I tried to install Cuda on Ubuntu 20.04 which runs from a flash disk (The installation flash disk which is created from iso). The solution was:

sudo add-apt-repository universe
sudo apt-get update
sudo apt-get install freeglut3 freeglut3-dev libxi-dev libxmu-dev

I have taken it from here

When I tried to install Cuda on an hard drive installation, the problem did not recreate.