How to install CUDA on lenny/ubuntu 8.04.1(8.10?)

I have installed CUDA on the following machine:
M/B: MSI K9N2 Diamond (nForce 780a which means GeForce8300)
Video: Asus ENGTX260

Display connector is connected to IGP(nForce 780a) not discrete graphic(GTX 260)

I have succeeded both lenny & ubuntu(server & desktop). Here is how to.

CUDA install to 64-bit lenny/buntu 8.04.1(8.10?)

a. The following assume lenny/ubuntu installation is complete.
b. Also the content heavily borrows:
http://lifeofaprogrammergeek.blogspot.com/…-in-ubuntu.html
c. ModCUDA is obtained from:
http://forums.nvidia.com/index.php?showtopic=80976
d. 64-bit related error is solved through CUDA forum thread
e. Downloading nVidia display driver, CUDA Toolkit and SDK in advance is strongly recommended.

  1. Login as root, and install 32-bit compatible lib

    apt-get install ia32-libs

  2. Prepare for kernel rebuild

    apt-get install make libc6-dev gcc-4.1 binutils

  3. Also install the associated linux-headers
    uname -r apt-cache search linux-headers

    apt-get install linux-headers-??

  4. Install nVidia display drivers
    a. Download driver from nVida site to /home/toshi, and make it executable

    chmod +x NVIDIA-Linux-x86_64-177.80-pkg2.run

    b. Set to appropriate alternative gcc version (currently 4.1)

    update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.1 41

    c. Choose appropriate gcc version for driver install

    update-alternatives --config gcc

    d. Install the build tools we need (this will install a bunch of X packages if X is not installed previously).

    apt-get install build-essential libglut3-dev -y

    e. If in X window, stop using it, and use console by hitting Ctrl+Alt+F1, login, and execute the rest of the commands

    /etc/init.d/gdm stop

    sh NVIDIA-Linux-x86_64-177.67-pkg2.run

    f. Edit /etc/X11/xorg.conf because we often endup with lousy monitor settings.
    g. If ubuntu edit /etc/default/linux-restricted-modules-common to resolve a driver conflict.

    add add ‘nv’ to DISABLED_MODULES (‘DISABLED_MODULES=“nv”’)

  5. If X windows is installed, examine its proper functioning by starting it.

  6. If lenny, install for pciutils, and g+±4.1

    apt-get install pciutils g+±4.1

    update-alternatives --install /usr/bin/g++ g++ /usr/bin/g+±4.1 41

    update-alternatives --config g++

  7. If no X is installed, obtain ModCuda, and run it

    ./ModCuda start

  8. Confirm nvidia devices

    ls /dev/nv*

  9. Install the CUDA Toolkit
    a. Download toolkit
    $ wget http://developer.download.nvidia.com/compu…ntu7.10_x86.run
    b. Make it executable

    chmod +x NVIDIA_CUDA_Toolkit_2.0_ubuntu7.10_x86_64.run

    c. Run

    ./NVIDIA_CUDA_Toolkit_2.0_ubuntu7.10_x86_64.run auto

A. Now exit from root, and login as a normal user

B. Append environment variables
$ echo “# CUDA stuff
PATH=$PATH:/usr/local/cuda/bin
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib
CFLAGS=-m64
export PATH
export LD_LIBRARY_PATH
export CFLAGS” >> ~/.bashrc
then restart the terminal for the changes to take effect.

C. Confirm nvcc working by
$ nvcc --version

D. Install the CUDA SDK
a. Download SDK
wget [url="http://developer.download.nvidia.com/compute/cuda/2_0/linux/sdk/NVIDIA_CUDA_SDK_2.02.0807.1535_linux.run"]http://developer.download.nvidia.com/compu....1535_linux.run[/url] b. Make it executable chmod +x ./NVIDIA_CUDA_SDK_2.02.0807.1535_linux.run
c. Run
$ ./NVIDIA_CUDA_SDK_2.02.0807.1535_linux.run

E. Compile and run an example: fluidsGL in X; otherwise choose a non-X example.
a. Change to a directory
cd NVIDIA_CUDA_SDK/ b. Compile all examples make
If there is an error of 64-bit related, edit common/common.mk (They are nvidia’s bugs, I believe)
2 lines: 73 and 125 -m32 --> -m64
c. If in X, run fluidsGL example
~/NVIDIA_CUDA_SDK/bin/linux/release/fluidsGL otherwise run deviceQuery example ~/NVIDIA_CUDA_SDK/bin/linux/release/deviceQuery

F. If ubuntu desktop, install the nVidia settings GUI
# apt-get install nvidia-settings
(If we install nvidia driver through debian way, we can do the same. But I have not confirmed it.)

This one should probably be made sticky.

Although I haven’t gone through this guide step-by-step, the part of switching gcc to 4.1 is also the same I did to make CUDA compile and run on Ubuntu 8.10.