Nvidia

Installing Cuda on Ubuntu 11.10

Here are steps to install and configure Nvidia Cuda on Ubuntu 11.10

Enjoy!

======================================================================================================================================================================

Installing CUDA 4.0 on Ubuntu 11.04 (Natty Narwhal)

NVIDIA recently released CUDA 4.0, their latest toolkit to harness the compute power of modern GPUs. However, installing NVIDIA's CUDA 4.0 on Ubuntu 11.04 can give problems. This mini how-to describes the steps to make it work.

Installing NVIDIA's CUDA 4.0 is not always straightforward on Ubuntu. On Ubuntu 10.10 it runs out-of-the-box, but CUDA 4.0 will not install on Ubuntu 10.04 and it will not install out-of-the-box on Ubuntu 11.04 either.

I was working on Ubuntu 10.04 when I decided to install CUDA 4.0. However, the CUDA 4.0 release notes state that Ubuntu 10.04 is not supported, so I decided to upgrade my Ubuntu, which gave me version 11.04. Here I encountered two problems. First, CUDA 4.0 relies on gcc-4.4 whereas Ubuntu 11.04 comes with gcc-4.5 by default. Second, CUDA 4.0 requires newer NVIDIA drivers than the ones that ship with Ubuntu 11.04. Fortunately, only a few relatively simple steps are required to make CUDA 4.0 work on Ubuntu 11.04.

Installing packages

I performed the following steps to install CUDA 4.0 on Ubuntu 11.04. Note that I wrote down these steps from my memory, but at least you should get the gist of it:

Install newer NVIDIA drivers and older versions of gcc and g++:

$ sudo apt-add-repository ppa:ubuntu-x-swat/x-updates $ sudo apt-get update $ sudo apt-get install gcc-4.4 g++-4.4 nvidia-current 

Selecting the right version of gxx

Now you have both the gxx-4.4 and gxx-4.5 versions on your system. So how do you select the right one? By default, your system uses the gxx-4.5 versions:

$ ls -l /usr/bin/g++ /usr/bin/gcc > /usr/bin/g++ -> g++-4.5 > /usr/bin/gcc -> gcc-4.5

We could make gxx-4.4 the default using sudo update-alternatives as described in the ubuntu gcc installation howto. However, I only want to use the gxx-4.4 versions if I'm working with CUDA and just leave gxx-4.5 as the default.

I found that the most convenient way to achieve this is to create two little gxx scripts that are executed instead of the /usr/bin/gxx ones. The scripts choose the right version of gxx based on the existence of an environment variable. I put these scripts in my ~/bin directory and placed them in my path before the /usr/bin entry.

Downloading CUDA

Now we are ready to install the CUDA toolkit for Ubuntu and the NVIDIA GPU Computing SDK. (By the way, the following steps are also required on other versions of Ubuntu.)

The SDK cannot find the NVIDIA drivers by itself. In order to fix this:

If everything worked out well, you have a working installation of CUDA 4.0 on your Ubuntu system! To test if everything is installed properly:

=======================================================================================

http://blog.ryant.org/2011/12/installing-cuda-toolkit-on-ubuntu-1110.html

Installing the CUDA Toolkit on Ubuntu 11.10

I ran into a couple of issues installing CUDA 4.0 on Ubuntu 11.10 and decided to write them up, here's how I went about it.

Install the required build tools

CUDA 4.0 does not support gcc 4.5+, I seemed to already have gcc 4.6 installed on my instance. There is no problem with having multiple versions of gcc installed side-by-side, we just have to install the 4.4 versions.

$ sudo apt-get install build-essential gcc-4.4 g++-4.4

Download the SDKs

Download the CUDA Toolkit for Ubuntu (the 10.10 version) and the GPU Computing SDK from here http://developer.nvidia.com/cuda-toolkit-40

These weigh in at around 210Mb and 140Mb respectively.

Install the CUDA Toolkit:

The CUDA Toolkit needs to be installed as root.

$ chmod 755 cudatoolkit_4.0.17_linux_64_ubuntu10.10.run

$ sudo ./cudatoolkit_4.0.17_linux_64_ubuntu10.10.run

Once you have completed installing this, add the CUDA bin location to your path - I did this in my .bashrc .

export PATH=$PATH:/usr/local/cuda/bin

And now you need to add the CUDA libs to your library search path, I already had the nvidia_settings.conf file here, though you can add any file with a .conf extension. The lines added are in bold.

$ cat /etc/ld.so.conf.d/nvidia_settings.conf

/usr/lib/nvidia-settings

/usr/local/cuda/lib64

/usr/local/cuda/lib

Now run ldconfig to pick up the changes.

$ sudo ldconfig

Install the GPU SDK

Much like the CUDA Toolkit, though this does not need to be installed by root, it defaults to ~/NVIDIA_GPU_Computing_SDK .

$ chmod 755 gpucomputingsdk_4.1.21_linux.run

$ ./gpucomputingsdk_4.1.21_linux.run

Link the 4.4 compilers

If you have multiple gcc versions installed, we need to make sure that nvcc (the CUDA compiler) picks up the 4.4 version. This can be done through flags for nvcc, however we need a link for it called gcc and g++.

Create a new directory in your home, called gcc-4.4 and create a link in here to the 4.4 version of gcc and g++.

$ cd

$ mkdir gcc-4.4

$ cd gcc-4.4

$ ln -s /usr/bin/g++-4.4 g++

$ ln -s /usr/bin/gcc-4.4 gcc

Set the compiler flag in the provided samples

In order to build the supplied samples we now need to modify the supplied MakeFile.

$ cd ~/NVIDIA_GPU_Computing_SDK/C/common

$ vim common.mk

Find a line that looks like:

NVCCFLAGS :=

And change it to look like:

NVCCFLAGS := -ccbin ~/gcc-4.4/

This flag tells nvcc where to find the gcc and g++ compilers.

Make the sample - deviceQuery

We will build the deviceQuery sample, this sample prints output of our CUDA device.

$ cd ~/NVIDIA_GPU_Computing_SDK/C/src/deviceQuery

$ make

$ cd ~/NVIDIA_GPU_Computing_SDK/C/bin/linux/release

$ ./deviceQuery

You should now see the output of the deviceQuery sample.

Using nvcc

You will need to use the -ccbin flag if you wish to use nvcc from the commandline, though this is quite easy:

$ nvcc -ccbin ~/gcc-4.4 my_app.cu

=======================================================================================

http://www.dickscheid.net/2011/10/19-cuda-ubuntu-1110/

Installing Cuda on Ubuntu 11.10

To install Cuda, I followed some hints on bottom of this thread, but also had to fix a few more issues.

=======================================================================================

1.NVIDIA GPU Computing Software Development Kit

CUDA SDK 4.0 Release Notes

    For more detailed instructions, see section II below.

    0. Install the NVIDIA Linux display driver by executing the file

    In addition, a NVIDIA Linux Display driver is needed to run CUDA code on an

    NVIDIA GPU.  CUDA 4.0 Release requires version 270 or newer version of the linux

    NVIDIA Display Driver.  Please see the NVIDIA CUDA Toolkit 4.0 Release notes

    for more details.

       a. For 32-bit linux distributions use:

          cudadriver_4.0_linux_32_270.xx.run

        Download from:

        http://developer.download.nvidia.com/compute/cuda/4_0/drivers/devdriver_4.0_linux_32_270.41.19.run

       b. For 64-bit linux distributions use:

          cudadriver_4.0_linux_64_270.xx.run

        Download from:

        http://developer.download.nvidia.com/compute/cuda/4_0/drivers/devdriver_4.0_linux_64_270.41.19.run

     

       For information on installing NVIDIA Linux display drivers, please refer to

       the NVIDIA Accelerated Linux Driver Set README and Installation Guide:

       http://us.download.nvidia.com/XFree86/Linux-x86/1.0-9755/README/index.html

    1. Install version 4.0 Release of the NVIDIA CUDA Toolkit by executing the file

       cudatoolkit_4.0_linux_*.run where * corresponds to your Linux distribution

        Download from:

        http://www.nvidia.com/object/thankyou.html?url=/compute/cuda/4_0/toolkit/cudatoolkit_4.0.17_linux_64_ubuntu10.10.run

       To install, run the cudatoolkit_4.0_linux_*.run script.  You will be prompted

       for the path to where you want to put the CUDA files. In the following we will

       call this path <CUDA_INSTALL_PATH>. It is recommended that you run the

       installer as root and use the default install path (/usr/local).

       Make sure that you add the location of the CUDA binaries (such as nvcc) to

       your PATH environment variable and the location of the CUDA libraries

       (such as libcuda.so) to your LD_LIBRARY_PATH environment variable.

       In the bash shell, one way to do this is to add the following lines to the

       file ~/.bash_profile from your home directory.

       a. For 32-bit operating systems use the following paths

        PATH=$PATH:<CUDA_INSTALL_PATH>/bin

        LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<CUDA_INSTALL_PATH>/lib

       

       b. For 64-bit operating systems use the following paths

        PATH=$PATH:<CUDA_INSTALL_PATH>/bin

        LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<CUDA_INSTALL_PATH>/lib64

       Then to export the environment variables add this to the profile configuration

        export PATH

        export LD_LIBRARY_PATH

    2. Install version 4.0 Release of the NVIDIA GPU Computing SDK by executing the file

       gpucomputingsdk_4.0_linux.run

        Download from:

        http://developer.download.nvidia.com/compute/cuda/4_0/sdk/gpucomputingsdk_4.0.17_linux.run

       To install, run the gpucomputingsdk_4.0_linux.run script.  You will

       be prompted for the path to where you want to put the CUDA SDK.  You can

       regard the CUDA SDK as user code (it is a set of examples), and therefore

       the default installation is in the current user's home directory

       (~/NVIDIA_GPU_Computing_SDK). You must either accept the default or specify a path

       to which the user has write permissions.

      The installer will prompt you to enter an installation path for the SDK or

       accept the default.  We will refer to the path you choose as

       SDK_INSTALL_PATH.

        (Note: The default installation folder <SDK_INSTALL_PATH> is "~/NVIDIA_GPU_Computing_SDK")      

    3. Build the SDK project examples. 

        a. cd <SDK_INSTALL_PATH>/C

        (Note: The default installation folder <SDK_INSTALL_PATH> is "~/NVIDIA_GPU_Computing_SDK")

        b. Build:

            - release    configuration by typing "make".

            - debug      configuration by typing "make dbg=1".

            - x86_64=1   configuration by typing "make x86_64=1"

            - i386=1     configuration by typing "make i386=1"

        Running make at the top level first builds libcutil, a utility library used

        by the SDK examples (libcutil is simply for convenience -- it is not a part

        of CUDA and is not required for your own CUDA programs).  Make then builds

        each of the projects in the SDK. 

        NOTES:

        - The release and debug configurations require a CUDA-capable GPU to run

          properly (see Appendix A.1 of the CUDA Programming Guide for a complete

          list of CUDA-capable GPUs).

        - To build just libcutil, type "make" (or "make dbg=1") in the "common"

          subdirectory:

            cd <SDK_INSTALL_PATH>/C/common

            make

  

      

    4. Run the examples (32-bit or 64-bit Linux)

       

        cd <SDK_INSTALL_PATH>/C/bin/linux/release

            matrixmul

        (Note: The default installation folder <SDK_INSTALL_PATH> is "~/NVIDIA_GPU_Computing_SDK")

       (or any of the other executables in that directory)

    See the next section for more details on installing, building, and running

    SDK samples.

    This package consists of a ".run" file. This is a self-extracting archive that

    decompresses its contents to a temporary folder and then installs the contents

    The archive is:

    gpucomputingsdk_4.0_linux.run: NVIDIA GPU Computing SDK Installer