1

Recently I got CUDA upgraded to version 9.2 and nvidia driver to nvidia-396 with a regular auto-update on my Ubuntu 16.04 Optimus-enabled laptop, with Intel video adapter active by default and NVidia accessed via bumblebee. Shortly after, I've tried to run a CUDA apllication (using optirun <command>), and found it doesn't work.

First thing I did was replacing all the entries of "nvidia-390" (if I remember right it was 390) in /etc/bumblebee/bumblebee.conf to "nvidia-396" - this helped me before more than once.

Still doesn't work (Cannot access secondary GPU - error: Could not load GPU driver). dmesg, and there is a reason:

[  314.733284] NVRM: The NVIDIA GeForce GT 520M GPU installed in this system is
               NVRM:  supported through the NVIDIA 390.xx Legacy drivers. Please
               NVRM:  visit http://www.nvidia.com/object/unix.html for more
               NVRM:  information.  The 396.26 NVIDIA driver will ignore
               NVRM:  this GPU.  Continuing probe...

Yes, my laptop is quite old, but with SSD and 12 Gb RAM I still don't feel much need to replace it. OK, looks like then I must live with nvidia-390:

sudo apt install nvidia-390

Was told that a lot of dependent packages will be uninstalled, including, it seems, all of CUDA 9.2. Damn. So likely I'm stuck with CUDA 9.0 as well. So, after uninstalling everything (and checkin in synaptic no packages from nvidia-396 or cuda-9.2 are left) I've tried to get it back:

sudo dpkg -i cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda

as per https://developer.nvidia.com/cuda-90-download-archive?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1604&target_type=debnetwork

Three commands ok, but the last one... Houston, we have a problem!

$ sudo apt install cuda
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package cuda

I've tried the solution from an answer on this Installing CUDA 8 on Ubuntu 16: Unable to locate package cuda question, that is:

dpkg -l | grep '^rc' | awk '{print $2}' | sudo xargs dpkg --purge

It did clean indeed lots of stuff, including some from cuda-9.2 related packages. However, the problem is still there - I can't install CUDA again, no matter I'm trying 9.0 or another version.

Any ideas?

3 Answers 3

1

This is a new problem:

  • the NVIDIA-supplied deb file contains driver 396.26 as required by CUDA 9.2.88.
  • the Version installed by ubuntu is 396.24.
  • the ubuntu package system sets dependencies such that an nvidia package, even a newer version, cannot overwrite the one installed by ubuntu.
  • IF you can get your hands on a pre-release of the ubuntu 396.26 driver package THEN

    1. you could install the ubuntu pre-release (might need to play with it in synaptic to get installed right)
    2. you can do the first three steps in the debnetwork instructions as shown
    3. Instead of sudo apt-get install cuda go into synaptic, search for lower-case cuda (it exists!), mark it to be installed, and update its dependencies.
    4. You will then have all the necessary files added, except the cuda link you clicked on will be broken (because it couldn't install its own version of 396.26).
    5. That's OK: it's a metapackage, it doesn't actually need to be installed, exactly sort of. Mark it for removal. When you hit apply, synaptic may barf on the remnants of the dead package, which looks bad but has the side effect of removing its corpse. Try again and if that was the only broken package, the install willl work.
    6. Depending on what else you've installed in what order, you may get to play a similar logic game getting rid of other broken packages, but it's doable. I strongly suggest not rebooting until you've got them in order. I'm sure you'll see the official release soon. If only you could find a pre-release copy, that would be nice...
      https://launchpad.net/~bstudent/+archive/ubuntu/nvidia-graphics-drivers-396.26-copy-of-staging-ppa-20180522
0

Here is an older workaround of NVIDIA and CUDA as solution for entire recognition of Optimus cards.

You have to un-install first the installed nvidia-drivers, reboot without nvidia-drivers. Then to proceed like here is described in following link. It is humblesome, but this works as solution for your older chipset.:

How can I Install Nvidia Driver GT 520 and Cuda 5.0 in Ubuntu13.04?

0

Well, after a while I was able to work around this problem. What exactly I did:

  • Cleaned up everything containing cuda in Synaptic.
  • Forced cuda-drivers package version to 390.xx in Synaptic.
  • Did apt update then dpkg --configure -a to resolve broken dependencies, then apt update again.

  • Then sudo apt install cuda did work but still offered me to install cuda 9.2 and upgrade to nvidia-396 in the process, despite I've locked the driver. But sudo apt install cuda-9-1 didn't compain and allowed me to install CUDA 9.1 with nvidia-390 (I've found that 9.1 driver also works with nvidia-390, that's why not 9.0).

After that (and a reboot), all my CUDA apps do work with optirun until now. :)

The only minor annoyance I've encountered later is that apt dist-upgrade still offered me to upgrade nvidia-390 (but regular apt upgrade didn't). Resolved that problem with apt-mark hold nvidia-390, and the package appears now as "locked" in Synaptic as well. Moreover, even if I try to run apt install cuda manually, now it throws an error:

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

but there are no broken packages packages in fact, so it looks like now I'm also safe from installing the wrong CUDA version accidentally.

2
  • I'm surprised you got 9.1 to work with your GPU, which has only a 2.1 compute capability.
    – ubfan1
    Jul 17, 2018 at 19:45
  • @ubfan1 Well indeed. The program I used to test (EWBF's CUDA Zcash miner 0.3.4b) still works, but once I've tried to compile something, I got into nvcc complains regarding compute_20 being unavailable. Looks like I'll have to downgrade to 8.0 once I must compile something anew. Yet the program mentioned (I believe built under 8.0) surprisingly still works with 9.1, that made me thinking everything works.
    – pazhosch
    Aug 8, 2018 at 21:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .