CUDA is a parallel computing platform and application programming interface (API) model created by Nvidia. I am supposed to install this package in my system.

Download Packages

The official downloading page for CUDA is Currently, the latest version of the CUDA is 9.2. We can chose the corresponding packages.

Since there is no package for 18.04, I tried to use 17.10, hope it works fine.

Install Packages

$ ll
total 8
drwxr-xr-x  2 yu yu   54 Sep 17 16:42 ./
drwxr-xr-x 18 yu yu 4096 Sep 17 15:26 ../
-rw-rw-r--  1 yu yu 2818 Sep 17 16:17 cuda-repo-ubuntu1710_9.2.148-1_amd64.deb
$ sudo apt-key adv --fetch-keys
Executing: /tmp/apt-key-gpghome.MKJ6VPC7sN/ --fetch-keys
gpg: requesting key from ''
gpg: key F60F4B3D7FA2AF80: public key "cudatools <>" imported
gpg: Total number processed: 1
gpg:               imported: 1
$ sudo dpkg -i cuda-repo-ubuntu1710_9.2.148-1_amd64.deb
... (a lot of logs)
$ sudo apt-get update
... (a lot of logs)
$ # sudo apt-get install cuda -y # this command may cause some error as follow
$ sudo apt-get -o Dpkg::Options::="--force-overwrite" install cuda -y

Error and Solution

An error comes here:

Unpacking nvidia-396 (396.44-0ubuntu1) ...
dpkg: error processing archive /var/cache/apt/archives/nvidia-396_396.44-0ubuntu1_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/x86_64-linux-gnu/', which is also in package libglx-mesa0:amd64 18.0.5-0ubuntu0~18.04.1
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

This error message terminated the installing process, and make apt command out of order as follow:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 cuda-drivers : Depends: nvidia-396 (>= 396.37) but it is not installed
 libcuda1-396 : Depends: nvidia-396 (>= 396.37) but it is not installed
 nvidia-396-dev : Depends: nvidia-396 (>= 396.37) but it is not installed
 nvidia-opencl-icd-396 : Depends: nvidia-396 (>= 396.37) but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

Found a solution here

We can fix the problem using command:

sudo apt-get -o Dpkg::Options::="--force-overwrite" install --fix-broken
Categories: Code


Ideals are like the stars: we never reach them, but like the mariners of the sea, we chart our course by them.


illia · February 20, 2019 at 03:15

Google Chrome 72.0.3626.109 Google Chrome 72.0.3626.109 GNU/Linux x64 GNU/Linux x64

I tried to spread this solution in popular threads so it might be easier to find it :)

Another thought that came to me – make a backup (snapshot) of my working system before I started to install Cuda :)

illia · February 18, 2019 at 08:52

Google Chrome 72.0.3626.109 Google Chrome 72.0.3626.109 GNU/Linux x64 GNU/Linux x64

The only solution that works for me. Thanks for saving me from reinstalling the whole system.

    yu · February 19, 2019 at 17:17

    Google Chrome 72.0.3626.109 Google Chrome 72.0.3626.109 Mac OS X  10.14.3 Mac OS X 10.14.3

    @illia Nice! Actually I searched the solution for a long time as well.

    Besides, you probably need to keep the command since it may required in the future when updating the packages.

James · January 12, 2019 at 18:40

Firefox 56.0 Firefox 56.0 GNU/Linux x64 GNU/Linux x64

Had this exact same problem. Thank you for taking the time to post a solution!

    yu · January 13, 2019 at 21:02

    Google Chrome 71.0.3578.98 Google Chrome 71.0.3578.98 Mac OS X  10.14.2 Mac OS X 10.14.2

    @James Glad to see this reply. have a nice day!

Leave a Reply

Your email address will not be published. Required fields are marked *