Monday, September 26, 2011

How to install CUDA 4.0 on Ubuntu 10.10 or later

First, you need to install the NVIDIA development drivers. Download the current version (270.41.19) here.
To install the dev drivers, reboot and go into recovery mode. Select the "Drop to root shell prompt" option. Now type:
sudo telinit 3
Login again using your username, then cd to the directory where you downloaded the drivers (e.g. ~/Downloads):
cd ~/Downloads
chmod u+x devdriver_4.0_linux_64_270.41.19.run
sudo ./devdriver_4.0_linux_64_270.41.19.run
Follow the instructions on the screen. Make sure you write to your xorg.conf file. When done reboot:
sudo reboot
Download the CUDA Toolkit from this page (Linux -> CUDA Toolkit for Ubuntu Linux 10.10).
cd ~/Downloads
chmod u+x cudatoolkit_4.0.17_linux_64_ubuntu10.10.run
sudo ./cudatoolkit_4.0.17_linux_64_ubuntu10.10.run
Finally, download the GPU Computing SDK from the above website.
cd ~/Downloads
chmod u+x gpucomputingsdk_4.0.17_linux
./gpucomputingsdk_4.0.17_linux
Add the these lines at the end of your ~/.profile (if your OS is 32-bit, remove the lib64 entry):
#CUDA stuff
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib:/usr/local/cuda/lib64:$LD_LIBRARY_PATH
Now you just need to compile the samples. Assuming you installed the SDK in your home directory:
cd ~/NVIDIA_GPU_Computing_SDK
make
You can now run one of the demos, e.g. the particle demo
~/NVIDIA_GPU_Computing_SDK/C/bin/linux/release/particles
and you should see something like this:


7 comments:

  1. what is the job of this command: sudo telinit 3
    after doing this it does not accept the password

    ReplyDelete
  2. Changes your system's runlevel to 3, which is needed by the driver to install. You then login with your normal user account. I can't think of any reason why it shouldn't accept your password.

    ReplyDelete
  3. When I run the command sudo telinit 3 runs some code and then displays the msg:

    grub-editenv: error: cannot open the file /boot/grub/grubenv
    [ 16.389598] init: plymouth-stop pre-start process (596) terminated with status 1

    Then it asks for my login, but it wont accept anything and it seems as if something is bugged. I'm running Ubuntu 11.10

    ReplyDelete
  4. I think
    "Ctrl+Alt+F1" and then
    "sudo service gdm stop" does the same thing

    ReplyDelete
  5. Hi Kary,
    I tried installing cuda 4.0 on ubuntu 10.10 but faced error nvidia-installer must be run as root

    Steps.
    1. Sudo telinit 3
    2. Login
    3. cd Downloads
    4. chmod u+x devdriver_4.0_linux_64_270.41.19.run
    5. ./devdriver_4.0_linux_64_270.41.19.run
    error appears nvidia-installer must be run as root.
    Could you help me with this

    ReplyDelete
  6. Thanks Kary for the useful thread.

    I was able to resolve my doubt using sudo before step 5 i.e sudo ./devdriver_4.0_linux_32_270.41.19.run

    Regards,
    Harshit

    ReplyDelete