2

I am trying to set up CUDA on my new Ubuntu 22.04 machine and following the instructions as per, official Nvidia guide But I get this when I try to install any package after CUDA installation.

I tried running sudo apt --fix-broken install but got this error log.

atif@aihwkit:~$ uname -r
5.15.0-43-generic
atif@aihwkit:~$ sudo apt-get install linux-headers-$(uname -r)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
linux-headers-5.15.0-43-generic is already the newest version (5.15.0-43.46).
linux-headers-5.15.0-43-generic set to manually installed.
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 cuda-drivers-515 : Depends: libnvidia-compute-515 (>= 515.48.07) but it is not going to be installed
                    Depends: nvidia-compute-utils-515 (>= 515.48.07) but it is not going to be installed
                    Depends: nvidia-kernel-common-515 (>= 515.48.07) but it is not going to be installed
                    Depends: nvidia-utils-515 (>= 515.48.07) but it is not going to be installed
 libnvidia-decode-515 : Depends: libnvidia-compute-515 (= 515.48.07-0ubuntu1) but it is not going to be installed
 nvidia-dkms-515 : Depends: nvidia-kernel-common-515 (= 515.48.07-0ubuntu1) but it is not going to be installed
 nvidia-driver-515 : Depends: libnvidia-compute-515 (= 515.48.07-0ubuntu1) but it is not going to be installed
                     Depends: libnvidia-extra-515 (= 515.48.07-0ubuntu1) but it is not going to be installed
                     Depends: nvidia-compute-utils-515 (= 515.48.07-0ubuntu1) but it is not going to be installed
                     Depends: nvidia-utils-515 (= 515.48.07-0ubuntu1) but it is not going to be installed
                     Depends: libnvidia-cfg1-515 (= 515.48.07-0ubuntu1) but it is not going to be installed
                     Recommends: libnvidia-compute-515:i386 (= 515.48.07-0ubuntu1)
                     Recommends: libnvidia-decode-515:i386 (= 515.48.07-0ubuntu1)
                     Recommends: libnvidia-encode-515:i386 (= 515.48.07-0ubuntu1)
                     Recommends: libnvidia-fbc1-515:i386 (= 515.48.07-0ubuntu1)
                     Recommends: libnvidia-gl-515:i386 (= 515.48.07-0ubuntu1)
 xserver-xorg-video-nvidia-515 : Depends: libnvidia-cfg1-515 (= 515.48.07-0ubuntu1) but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
atif@aihwkit:~$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  libnvidia-cfg1-515 libnvidia-compute-515 libnvidia-extra-515 nvidia-compute-utils-515
  nvidia-kernel-common-515 nvidia-utils-515
The following NEW packages will be installed:
  libnvidia-cfg1-515 libnvidia-compute-515 libnvidia-extra-515 nvidia-compute-utils-515
  nvidia-kernel-common-515 nvidia-utils-515
0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
208 not fully installed or removed.
Need to get 67.5 MB of archives.
After this operation, 236 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64  libnvidia-compute-515 515.48.07-0ubuntu1 [45.0 MB]
Get:2 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64  nvidia-compute-utils-515 515.48.07-0ubuntu1 [271 kB]
Get:3 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64  nvidia-kernel-common-515 515.48.07-0ubuntu1 [21.7 MB]
Get:4 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64  libnvidia-extra-515 515.48.07-0ubuntu1 [56.8 kB]
Get:5 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64  nvidia-utils-515 515.48.07-0ubuntu1 [337 kB]
Get:6 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64  libnvidia-cfg1-515 515.48.07-0ubuntu1 [85.4 kB]
Fetched 67.5 MB in 3s (20.9 MB/s)             
debconf: delaying package configuration, since apt-utils is not installed
(Reading database ... 80853 files and directories currently installed.)
Preparing to unpack .../0-libnvidia-compute-515_515.48.07-0ubuntu1_amd64.deb ...
Unpacking libnvidia-compute-515:amd64 (515.48.07-0ubuntu1) ...
dpkg: error processing archive /tmp/apt-dpkg-install-87d4eZ/0-libnvidia-compute-515_515.48.07-0ubuntu1_amd64.deb (--unpack):
 unable to make backup link of './usr/lib/x86_64-linux-gnu/libcuda.so.515.48.07' before installing new version: Invalid cross-device link
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Preparing to unpack .../1-nvidia-compute-utils-515_515.48.07-0ubuntu1_amd64.deb ...
Unpacking nvidia-compute-utils-515 (515.48.07-0ubuntu1) ...
dpkg: error processing archive /tmp/apt-dpkg-install-87d4eZ/1-nvidia-compute-utils-515_515.48.07-0ubuntu1_amd64.deb (--unpack):
 unable to make backup link of './usr/bin/nvidia-cuda-mps-control' before installing new version: Invalid cross-device link
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Preparing to unpack .../2-nvidia-kernel-common-515_515.48.07-0ubuntu1_amd64.deb ...
Unpacking nvidia-kernel-common-515 (515.48.07-0ubuntu1) ...
dpkg: error processing archive /tmp/apt-dpkg-install-87d4eZ/2-nvidia-kernel-common-515_515.48.07-0ubuntu1_amd64.deb (--unpack):
 unable to make backup link of './lib/firmware/nvidia/515.48.07/gsp.bin' before installing new version: Invalid cross-device link
Preparing to unpack .../3-libnvidia-extra-515_515.48.07-0ubuntu1_amd64.deb ...
Unpacking libnvidia-extra-515:amd64 (515.48.07-0ubuntu1) ...
dpkg: error processing archive /tmp/apt-dpkg-install-87d4eZ/3-libnvidia-extra-515_515.48.07-0ubuntu1_amd64.deb (--unpack):
 unable to make backup link of './usr/lib/x86_64-linux-gnu/libnvidia-allocator.so.515.48.07' before installing new version: Invalid cross-device link
Preparing to unpack .../4-nvidia-utils-515_515.48.07-0ubuntu1_amd64.deb ...
Unpacking nvidia-utils-515 (515.48.07-0ubuntu1) ...
dpkg: error processing archive /tmp/apt-dpkg-install-87d4eZ/4-nvidia-utils-515_515.48.07-0ubuntu1_amd64.deb (--unpack):
 unable to make backup link of './usr/bin/nvidia-debugdump' before installing new version: Invalid cross-device link
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Preparing to unpack .../5-libnvidia-cfg1-515_515.48.07-0ubuntu1_amd64.deb ...
Unpacking libnvidia-cfg1-515:amd64 (515.48.07-0ubuntu1) ...
dpkg: error processing archive /tmp/apt-dpkg-install-87d4eZ/5-libnvidia-cfg1-515_515.48.07-0ubuntu1_amd64.deb (--unpack):
 unable to make backup link of './usr/lib/x86_64-linux-gnu/libnvidia-cfg.so.515.48.07' before installing new version: Invalid cross-device link
Errors were encountered while processing:
 /tmp/apt-dpkg-install-87d4eZ/0-libnvidia-compute-515_515.48.07-0ubuntu1_amd64.deb
 /tmp/apt-dpkg-install-87d4eZ/1-nvidia-compute-utils-515_515.48.07-0ubuntu1_amd64.deb
 /tmp/apt-dpkg-install-87d4eZ/2-nvidia-kernel-common-515_515.48.07-0ubuntu1_amd64.deb
 /tmp/apt-dpkg-install-87d4eZ/3-libnvidia-extra-515_515.48.07-0ubuntu1_amd64.deb
 /tmp/apt-dpkg-install-87d4eZ/4-nvidia-utils-515_515.48.07-0ubuntu1_amd64.deb
 /tmp/apt-dpkg-install-87d4eZ/5-libnvidia-cfg1-515_515.48.07-0ubuntu1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
Atif Ali
  • 565
  • The dependencies on the Nvidia debs have always been a mess. I gave up on them and use the .run file to install. I set up my system with my selected Nvidia 515 driver, then reject any offer the .run file makes for a new driver. I do not use sudo on the .run file. The 11.7 insists on creating a /usr/local/cuda-11.7 directory, so temporarily change permissions on /usr/local. Then move it to where you want it. see https://askubuntu.com/questions/1077061/how-do-i-install-nvidia-and-cuda-drivers-into-ubuntu/1077063#1077063 No need at all to mix nvidia libraries with system libs. – ubfan1 Aug 01 '22 at 17:00
  • I ended up using nvidia/cuda docker image to solve my issues. But still, a local installation is preferable – Atif Ali Aug 02 '22 at 12:34
  • 1
    You may answer your own question, and if it gets upvoted, accept it after a few days -- helping others and gaining some rep in the process. – ubfan1 Aug 02 '22 at 16:48
  • Thank you, @ubfan1. For now, even the question is not gaining any upvotes. I have posted my solution. I hope it will help others with similar issues. – Atif Ali Aug 03 '22 at 08:19

1 Answers1

1

Update:

Consider using a deep-learning docker image available at,

https://github.com/matifali/dockerdl

Old solution:

After trying many things, I was unable to solve the dependencies problem. Finally, I ended up using the official Nvidia CUDA image and installed my requirements on top of that.

Use the devel version if you are thinking of building something from the source.

I used,

nvidia/cuda:11.7.1-devel-ubuntu22.04

Atif Ali
  • 565
  • 1
    I was trying to go from Cuda 10.6 to Cuda 11.7 on Ubuntu 22.04 because Windows laptop was using Cuda 11.7. In all it was a very horrendous experience. The key ring PGP is only given for Nvidia Cuda Toolkit 11.7 and not for earlier versions. In the end I used a highly dangerous move, that I probably shouldn't have but had been completely unable to upgrade or get rid of Cuda otherwise. This is what I did: sudo apt-get -o Dpkg::Options::="--force-overwrite" --fix-broken install due to the error being dpkg indicating an issue with overwriting. – Sildeag Aug 30 '22 at 22:21
  • 1
    This was the whole reason I switched to the docker image. apt is a mess – Atif Ali Aug 31 '22 at 07:21
  • In my case I'm trying to use a fake-cam project on Ubuntu in order to get background blur or replacement. How should I use the docker image in order to have fake-cam use CUDA to improve its performance? What I really want in the end is to make v4l2 use the GPU thru NVidia drivers. – Sidney de Moraes Sep 26 '22 at 14:46