How to install CUDA 5.0 on Ubuntu 12.04 LTS

These steps helped me to successfully install CUDA 5.0 on many Ubuntu 12.04 LTS computers, including headless servers that do not run X windows.

1. Make sure the computer has a NVIDIA graphics card that is recognized by Linux. This can be done as shown here.

2. Uninstall all NVIDIA drivers and kernel modules. Steps to do this are described here.

3. Download CUDA 5.0 installer for Linux. There is no installer for Ubuntu 12.04 LTS, so download the installer for Ubuntu 11.10 instead.

4. Make the installer executable and run it as sudo. When asked to install the NVIDIA driver, choose Yes. This is important, allow the installer to install its own drivers. Let it install CUDA to the default location: /usr/local/cuda-5.0/

5. If the computer is a headless Ubuntu server which is not connected to a display or does not run X, then device files for your card are not created by default. So, create a shell script file (say /home/joe/NvidiaDevCreator.sh) with the following code:

Add the line /home/joe/NvidiaDevCreator.sh to /etc/rc.local and restart the system. This ensures that the necessary dev files are created on every startup for access by CUDA programs.

6. Add the following to your bashrc:

This ensures that the CUDA libraries are available for dynamic loading by CUDA programs.

That is all! Any user on your Ubuntu 12.04 system should now be able to compile and run CUDA 5.0 programs without any special access permissions or privileges :-)

Note: I had problems when I used the nvidia-current and nvidia-current-updates drivers from Ubuntu. Only by uninstalling them and using the drivers that ship with the CUDA installer was I able to get CUDA working.

Tried with: NVIDIA GeForce 9900 GT and NVIDIA GTX 690

About these ads

5 thoughts on “How to install CUDA 5.0 on Ubuntu 12.04 LTS

  1. Hi there!
    I would like to thank you for your post and also contribute a little bit. I was not finding a good guide for a server install. I found your solution to work well here on a newer system with a newer cuda driver:

    System: Headless Ubuntu Server 14.04 LTS
    GPU: Nvidia Geforce 8400 GS
    Driver: CUDA 6 (RUN) for Ubuntu 13.04

    It was an updated fresh install and I had the kernel headers installed as well (don’t know if it would be necessary on this case).

    I had to run the installer with the –override compiler flag otherwise the installer will not install the toolkit because of the gcc version.
    $ sudo ./cuda_6.0.37_linux_64.run –override compiler

    Also, the first time you run the installer a reboot is need to disable the open source driver. Then you have to run the installation script again. YOU WILL NEED TO “REINSTALL” THE DRIVERS WHEN YOU RUN AGAIN OR INSTALLATION WILL FAIL!

    I have created the NvidiaDevCreator.sh at /usr/local/bin/NvidiaDevCreator.sh. Would that be a problem? It may be useful to point that a chmod +x /usr/local/bin/NvidiaDevCreator.sh is needed to make the script executable as well.

    Then I just changed:
    export CUDA_ROOT=/usr/local/cuda-5.0
    To point to the correct location (cuda 6)
    export CUDA_ROOT=/usr/local/cuda-6.0

    And did not change anything else.
    Seems to be fine and working.

    Cheers!

    • Sorry to double-post but I really couldn’t find a way to edit my previous post. It turns out that people will indeed need to have the kernel headers and build utilities installed. So just to get it complete here, run:
      sudo apt-get install gcc make build-essential linux-headers-$(uname -r)
      BEFORE doing anything else on this guide.

      I had to reinstall everything (testing time! LOL) so I was able to be sure of the build environment being needed (it is kind of obvious anyways).

      Cheers!

      • Tavbits: Thanks for sharing! I’ll be trying CUDA 6 on Ubuntu 14.04 soon and your comments will be useful then :-)

        • Glad I may be able to give some back :)

          I have reproduced this again on Debian 7.5 Wheezy.

          I was also able to “solve” the problem of the X libraries that are absent during install: libGLU.so, libX11.so, libXi.so, libXmu.so. The installer complain about these “recommended libraries” not being available. I am not that sure they would be needed for CUDA to be 100% on a headless server since it does work even when missing those libraries.

          Anyways, to have all installed one could:
          sudo apt-get install mpich2 libglui-dev libxmu-dev libxi-dev
          And then proceed with installing (or re-installing) the cuda driver.

          I have created a guide here:
          http://wp.me/p11PwI-9
          (there is a reference to this post there).

          Cheers! and thanks again!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s