CUDA 6 installation on Ubuntu 14.04

dear All,
im am REALLY sure that i was able to install and correctly use CUDA 6, i also compiled and run the device query sample, on ubuntu 14.04, just the day after the release. Then i had to install many other many other things and libraries, but something went wrong, as you can see from this post: where i was also reporting the problem. After trying all the solutions suggested in the linked discussions i decided to reinstall. I am sure the problem was with mesa libraries.
Now i am unable to install correctly CUDA 6 again. Now it’s the second time i have only the screen at 640x480. If i run the installation it says it’s impossible for him stop and replace the nouveau drivers, i have of course given the command to stop lightdm. Moreover if i put nouveau in the blacklist for the conf files things does not changes…
please help me…


NVidia does not officially support 14.04 yet. So all efforts are at your own risk. But I just spent full day dealing with this so I’m going to document it.

Basically you can almost use nvidia-331 driver package that Nvidia provides on their repository, except some dependencies are broken. So the way to deal with it is either to rebuild that driver package (then you maintain proper APT tree of packages, this is what I did and what I will document below) or to install CUDA-6.0 from their tar/run and install nvidia-331 package from Ubuntu 14.04 (they will conflict in driver and one from Nvidia should be removed; you basically want to keep slightly lower version driver from Ubuntu and have /usr/local/cuda-6.0 directory from Nvidia install).

Since I want to make sure future packages Nvidia may provide in their repository work, I’m providing feedback here on how to fix it in “debian” way and will send email to someone at NVidia pointing to this thread.

Ok. So assuming you started fresh from Ubuntu 14.04, you may already have some nvidia driver installed (nvidia-304 or nvidia-311 or nvidia-common) but they will only support CUDA 5.5. To get CUDA 6.0 you want to first add Nvidia repository - this can be done by either downloading from Nvidia (select DEB from CUDA download site for Linux Ubuntu 13.04) cuda-repo-ubuntu1304_6.0-37_amd64.deb and installing it or by manually adding line:
deb /
to /etc/apt/sources.list

All packages will install fine from that repository except the drivers nvidia-331 package. So that one you will need to rebuild and add to your local repository. You can get that package directly from Nvidia site:
You want to npack the debian file after download. There are better ways of doing it but I’m afraid I’m used to the most manual way - I unarchive it and untar what’s inside. Lets assume you’re in the directory where you downloaded nvidia-310_331.62-0ubuntu1_amd64.deb into. In there do:

mkdir nvidia-331

cd nvidia-331

ar x …/nvidia-310_331.62-0ubuntu1_amd64.deb

mkdir DEBIAN


tar xf …/control.tar*

cd …

tar xf data.tar*

rm * (you will get warnings here, ignore)

Now nvidia-331 has directory from which new debian package can be created. You want to modify the control file (in DEBIAN subdirectory) and fix the dependencies.

vi DEBIAN/control (obviously you can use something other than vi here)

You want to remove “xorg-video-abi-11 | xorg-video-abi-12 | xorg-video-abi-13 | xorg-video-abi-14” from Depends line and libopencl1 from Conflicts, Replaces, Provides (removing libopencl1 is optional if you just want CUDA6, but it is needed if you want to also install wine). You also want to increase the version number (actually its enough to just increase number before or after ubuntu in version line, I was debugging something else to increase version) and modify to indicate its your custom version. My control after modifications looks like this:

Package: nvidia-331
Source: nvidia-graphics-drivers-331
Version: 331.63-1ubuntu1-william-62to63
Architecture: amd64
Maintainer: Ubuntu Core Developers
Installed-Size: 262008
Depends: x11-common (>= 1:7.0.0), make, sed (>> 3.0), dkms, linux-libc-dev, libc6-dev, patch, acpid, libc6 (>= 2.2.5), libgl1, libx11-6, libxext6, zlib1g (>= 1:1.1.4), xserver-xorg-core
Recommends: nvidia-settings-331, nvidia-persistenced
Conflicts: xorg-driver-binary
Replaces: xorg-driver-binary
Provides: libcuda-5.0-1, nvidia-driver-binary, opencl-icd, xorg-driver-binary, xorg-driver-video
Section: restricted/misc
Priority: optional

Good so if you have done as above you’re ready to create a new debian package. Do this with:

cd …

dpkg-deb -b nvidia-331

Now you have new nvidia-331.deb file in the directory where you downloaded original file. You can if you want rename it to correspond to version string you chose.

We need to create custom repository to put this into. Normally you’d have .changes file for repository from Debian build. Having just .deb is not common and most repository tools can’d deal with it. But reprepro local repository package can. The documentation steps below on how to do it are based on So to create a repository do:

apt-get install reprepro

mkdir /usr/local/debian-archive

mkdir /usr/local/debian-archive/conf

mkdir /usr/local/debian-archive/dists

mkdir /usr/local/debian-archive/incoming

mkdir /usr/local/debian-archive/indices

mkdir /usr/local/debian-archive/logs

mkdir /usr/local/debian-archive/pool

mkdir /usr/local/debian-archive/project

mkdir /usr/local/debian-archive/tmp

echo “allow * by unsigned” > /usr/local/debian-archive/conf/uploaders

cat << EOF > /usr/local/debian-archive/conf/incoming

Name: default
IncomingDir: incoming
TempDir: tmp
Allow: trusty
Cleanup: on_deny on_error

cat << EOF > /usr/local/debian-archive/conf/distributions

Origin: Local
Label: Local
Suite: trusty
Codename: trusty
Version: 14.04
Architectures: i386 amd64 source
Components: main
Description: Locally modified (or backported) packages
DebOverride: …/indices/override.trusty.main
UDebOverride: …/indices/override.trusty.main.debian-installer
DscOverride: …/indices/override.trusty.main.src
DebIndices: Packages Release . .gz .bz2
UDebIndices: Packages . .gz .bz2
DscIndices: Sources Release .gz .bz2
Contents: . .gz .bz2
Log: packages.local.log

touch /usr/local/debian-archive/indices/override.trusty.main

touch /usr/local/debian-archive/indices/override.trusty.main.debian-installer

touch /usr/local/debian-archive/indices/override.trusty.main.src

reprepro -Vb /usr/local/debian-archive

Now you are going to add the custom nvidia-331 package to this repository:

reprepro -b /usr/local/debian-archive includedeb trusty nvidia-331.deb

Next step is adding local repository to apt, add this line to /etc/apt/sources.list
deb file:///usr/local/debian-archive dists/trusty/main/binary-amd64/
Update your apt cache after that:

apt-get update

If everything has been done right you can now finally add CUDA6 by just doing:

apt-get install cuda

Everything below is optional if you want to also install wine and if you want to use bumblebee. So wine has a conflict with drivers because of libopencl. We actually already fixed the conflict with changes to nvidia-331 but result is that if you just do “apt-get install wine” it will want to install different opencl library which may not be optimal or may lead to conflicts - but feel free to just do it because probably it is all ok and besides its probably not the case that you’re going to use opencl from wine anyway. In case you want setup proper Nvidia library you will need to create another custom package. You download nvidia-libopencl1-331_331.38-0ubuntu7_amd64.deb (and yes, I checked that library is exactly the same as in newer driver package) from and then unpack:

mkdir nvidia-libopencl1-331

cd nvidia-libopencl1-331

ar x …/nvidia-libopencl1-331_331.38-0ubuntu7_amd64.deb

mkdir DEBIAN


tar xf …/control.tar*

cd …

tar xf data.tar*

rm *

vi DEBIAN/control

For modifications here you want to ensure it has the same version as cuda driver and you want to add
libopencl-1.1-1 to provides, add nvidia-331 to depends and add
Multi-Arch: foreign
line because otherwise wine will not install as it requires i386 support even for amd64 system (and nvidia-libopencl package does include i386 libraries in proper multiarch directories). My control looked like this:

Package: nvidia-libopencl1-331
Source: nvidia-graphics-drivers-331
Version: 331.63-1ubuntu8-william
Architecture: amd64
Maintainer: Ubuntu Core Developers
Installed-Size: 85
Depends: libc6 (>= 2.2.5), nvidia-331
Suggests: nvidia-opencl-icd-331
Conflicts: libopencl1
Replaces: libopencl1
Provides: libopencl1, libopencl-1.1, libopencl-1.1-1
Section: restricted/misc
Priority: optional
Multi-Arch: foreign
Description: NVIDIA OpenCL Driver and ICD Loader library

Now you create a debian package and add it to your local repository:

cd …

dpkg-deb -b nvidia-libopencl1-331

reprepro -b /usr/local/debian-archive includedeb trusty nvidia-libopencl1-331.deb

apt-get update

You install wine together with this package:

apt-get install wine nvidia-libopencl1-331:amd64

Last thing related to Nvidia to get to work for me was bumblebee. It will not work as is because with newest driver Nvidia added 2nd kernel module nvidia-uvm.ko in addition to just nvidia.ko. This is what I put in /etc/bumblebee/bumblebee.conf to make it work:


Also I put driver=nvidia in [bumblebeed] section because I don’t want fallback to nouveau (tested, it didnt work for me). The only problem is bumblebeed doesn’t know there are two kernel modules and not one and while it will load nvidia driver and run application with nvidia, it will not not unload it after its done. You can unload driver manually with “rmmod nvidia-uvm; rmmod nvidia” and if you want can just create a shell script for calling optirun that will do it.

Hope this is helpful!


CUDA 6.5RC should natively support Ubuntu 14.04 64-bit

Yes, you have to get rid of nouveau. Blacklisting it alone is not necessarily enough. You also have to remove it from the initrd image. Something like this as root:

echo -e “blacklist nouveau\noptions nouveau modeset=0” > /etc/modprobe.d/disable-nouveau.conf

update-initramfs -u

and reboot. Then use the CUDA 6.5RC runfile installer.

And this doesn’t address optimus/bumblebee.

I’m going to try CUDA 6.5 next week. But my preference is to setup proper APT repositories for standard updates rather than run packages like Nvidia typically provides. I’m part of Nvidia early access program, and Ubuntu beta tester as well. But had been too busy during most of the year to try this all before and provide feedback. Besides I don’t think I will benefit much from CUDA 6 - my laptop has Quadro 1000M.

I did not find that having nouveau was a big deal, I just don’t want bumblebee to load it by accident. But yes, I did blacklist and I didn’t document it above. nvidia-331 drivers package includes /lib/nvidia-331/modprobe.conf but it did not properly install it. This can be done with:
ln -s /lib/nvidia-331/modprobe.conf /etc/modprobe.d/nvidia-331.conf