Getting the nvidia-346 drivers to cooperate with CUDA on Linux Mint

UPDATE: As of March 17th, Nvidia’s repository has been updated to support the 346 driver, alongside the release of the Cuda 7 toolkit.

——————————————————————————–

I recently discovered that FFmpeg added support for the NVENC encoder and thought it would be interesting to play around with. Turns out, that ended up taking a lot more work than I anticipated and it wasn’t FFmpeg’s fault. The beginning of my trouble is that NVENC support was only added to the Linux driver in version 346.16. However, the Ubuntu/Mint repository’s newest offering is 331.113. Fortunately, the xorg-edgers ppa has newer drivers available (refer to the launchpad page), so that turns out to not be much of an issue.

$ sudo apt-add-repository ppa:xorg-edgers/ppa && sudo apt-get update
$ sudo apt-get install nvidia-346 nvidia-346-dev nvidia-346-uvm libcuda1-346 nvidia-libopencl1-346 nvidia-icd-346

Now for the CUDA installation. The download page has two options: a standalone installer and a package repository.

For whatever reason, I tried the standalone installer first (currently toolkit version 6.5.14). I’m not going to go into too much detail, because it didn’t work (if you just want to know what did work, then skip the next bit). It installed fine though. I went into the samples and found 1_Utilities/deviceQuery, a suitable program to test my installation. It compiled fine. Then, this happened:

$ ./deviceQuery
./deviceQuery Starting...
CUDA Device Query (Runtime API) version (CUDART static linking)
cudaGetDeviceCount returned 35
-> CUDA driver version is insufficient for CUDA runtime version
Result = FAIL

Well, that doesn’t really make sense. The installer is bundled with driver version 340.29, which I declined to install. But, a newer driver is supposed to be fine. What gives? I also tried toolkit version 6.5.19 to no avail. Next, I thought that since I have a sample compiled, I just need the runtime, so I removed the toolkit. That didn’t help either.

$ ./deviceQuery
./deviceQuery Starting...
CUDA Device Query (Runtime API) version (CUDART static linking)
cudaGetDeviceCount returned 30
-> unknown error
Result = FAIL

Hooray! An even more ambiguous error. Fine, time to try the repository instead. Repositories always make things easy, right?

After adding the repository:

$ sudo apt-get update && sudo apt-get install cuda

…And it wants to replace the nvidia-346 drivers with the nvidia-340 drivers. Poking around the repository, they only have packages up to 340.29. Normally, I wouldn’t be too bothered by that, but I need the 346 drivers for NVENC support. So, there must be a dependency issue somewhere in the dozens of packages that need to be installed. The culprit turns out to be cuda-drivers, whose dependencies are:

Depends: nvidia-340 (>=340.29), nvidia-340-uvm (>=340.29), nvidia-340-dev (>=340.29), nvidia-modprobe (>=340.29), nvidia-settings (>=340.29), libcuda1-340 (>=340.29), nvidia-libopencl1-340 (>=340.29), nvidia-opencl-icd-340 (>=340.29)

I got around this by making my own cuda-drivers package with dependencies changed to the 346 equivalents.

$ wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-drivers_340.29-1_amd64.deb
$ mkdir cuda-drivers && cd cuda-drivers
$ dpkg-deb -x ../cuda-drivers_340.29-1_amd64.deb .
$ dpkg-deb -e ../cuda-drivers_340.29-1_amd64.deb

Now, edit DEBIAN/control to change everything to the 346 version, except nvidia-modprobe (as it is not provided by xorg-edgers).

Package: cuda-drivers
Version: 346.47-1
Maintainer: cudatools <cudatools@nvidia.com>
Architecture: amd64
Section: devel
Priority: optional
Installed-Size: 8
Depends: nvidia-346 (>=346.47), nvidia-346-uvm (>=346.47), nvidia-346-dev (>=346.47), nvidia-modprobe (>=340.29), nvidia-settings (>=346.47), libcuda1-346 (>=346.47), nvidia-libopencl1-346 (>=346.47), nvidia-opencl-icd-346 (>=346.47)
Description: CUDA Driver meta-package
Meta-package containing all the available packages related to the NVIDIA driver.

Make the new package:

$ dpkg-deb -b . ../cuda-drivers_346.47-1_amd64.deb

For the lazy, here’s the package: cuda-drivers_346.47-1_amd64. I installed this newly created package and afterwards, the cuda package installs without issue, but does it work?

$ ./deviceQuery
./deviceQuery Starting...
 
CUDA Device Query (Runtime API) version (CUDART static linking)
 
Detected 1 CUDA Capable device(s)
 
Device 0: "GeForce GTX 770"
CUDA Driver Version / Runtime Version 7.0 / 6.5
CUDA Capability Major/Minor version number: 3.0
Total amount of global memory: 2048 MBytes (2147155968 bytes)
( 8) Multiprocessors, (192) CUDA Cores/MP: 1536 CUDA Cores
GPU Clock rate: 1163 MHz (1.16 GHz)
Memory Clock rate: 3505 Mhz
Memory Bus Width: 256-bit
L2 Cache Size: 524288 bytes
Maximum Texture Dimension Size (x,y,z) 1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)
Maximum Layered 1D Texture Size, (num) layers 1D=(16384), 2048 layers
Maximum Layered 2D Texture Size, (num) layers 2D=(16384, 16384), 2048 layers
Total amount of constant memory: 65536 bytes
Total amount of shared memory per block: 49152 bytes
Total number of registers available per block: 65536
Warp size: 32
Maximum number of threads per multiprocessor: 2048
Maximum number of threads per block: 1024
Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
Max dimension size of a grid size (x,y,z): (2147483647, 65535, 65535)
Maximum memory pitch: 2147483647 bytes
Texture alignment: 512 bytes
Concurrent copy and kernel execution: Yes with 1 copy engine(s)
Run time limit on kernels: Yes
Integrated GPU sharing Host Memory: No
Support host page-locked memory mapping: Yes
Alignment requirement for Surfaces: Yes
Device has ECC support: Disabled
Device supports Unified Addressing (UVA): Yes
Device PCI Bus ID / PCI location ID: 1 / 0
Compute Mode:
< Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >
 
deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 7.0, CUDA Runtime Version = 6.5, NumDevs = 1, Device0 = GeForce GTX 770
Result = PASS

Victory!

Someday, this post will clearly be irrelevant, as newer packages make it to official repositories, but it’s hard to guess when that might be.

7 thoughts on “Getting the nvidia-346 drivers to cooperate with CUDA on Linux Mint

  1. Even though now “irrelevant,” thanks for writing this. It’s good to see this list of all the moving parts necessary to get CUDA working on Linux. I had trouble as well getting CUDA set up… before CUDA 7, but thankfully after CUDA 7 much of what you describe above happens behind the scenes.

  2. So helpful. Maybe irrelevant for the very issue you had but a great source of inspiration to solve the problem I faced with installing cuda-7-5.
    For some reason the dependencies required nvidia-settings >= 352.68 but I never found a newer version than the 346 my Mint 17.2 is using.
    Based on your explanation I could edit the control file and go further.

    Thank you so much for writing this.
    Regards,
    Alex

  3. Really helpful. It inspired me a lot for the similar problem I was facing with installing CUDA 7.5. Again Thank You very much !!!

Leave a Reply

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