Ubuntu – installing CUDA on Ubuntu 12.10 GeForce GT 630

12.10cudanvidia

what are your impressions about installing CUDA API on Ubuntu 12.10? I've read about some incompatibility with gcc (here i.e.), that you have to reinstall v.4.4, but even then you can have crush of your system. since I don't want to reinstall sys again (I did it a couple of times recently : p) I'd like to ask you if this script is safe on my x64 Ubuntu 12.10 on amd proc.

my accepted answer allowed to install CUDA 3 components with 4.6, but driver is not appropriate, maybe only gcc-4.4 and g++-4.4 is indeed appropriate – now I try 4.4

so please read Soroosh129 answer and then apply my additional suggestions while doing as he described.

additional notes:

you have to add CUDA to PATH and LD_LIBRARY_PATH, I have added following to .bashrc in my home and in root home folder:

export PATH=$PATH:/usr/local/cuda-5.0/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-5.0/lib64:/lib

finally I have installed without driver. just CUDA Toolkit and samples without driver, and use my default "NVIDIA binary Xorg driver, kernel module and VDPAU library from nvidia-current".
with result

> Toolkit:Installed, Samples:Instaled

 but also 

> "Incomplete installation. this didn't install CUDA driver. driver
> version at least 304.54 required for CUDA 5.0 to work"

probably this is correctly installed, I have done make in clock sample with following result:

me@comp:/usr/local/cuda-5.0/samples/0_Simple/clock$ ls
clock.cu  Makefile  NsightEclipse.xml  readme.txt
me@comp:/usr/local/cuda-5.0/samples/0_Simple/clock$ sudo make
[sudo] password for me: 
/usr/local/cuda-5.0/bin/nvcc -m64  -gencode arch=compute_10,code=sm_10 -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -I/usr/local/cuda-5.0/include -I. -I.. -I../../common/inc -o clock.o -c clock.cu
g++ -m64 -o clock clock.o -L/usr/local/cuda-5.0/lib64 -lcudart 
mkdir -p ../../bin/linux/release
cp clock ../../bin/linux/release
me@comp:/usr/local/cuda-5.0/samples/0_Simple/clock$ ./clock
CUDA Clock sample
GPU Device 0: "GeForce GT 630" with compute capability 2.1

Total clocks = 54830
me@comp:/usr/local/cuda-5.0/samples/0_Simple/clock$ 

and another example:

me@comp:/usr/local/cuda-5.0/samples/0_Simple$ cd asyncAPI
me@comp:/usr/local/cuda-5.0/samples/0_Simple/asyncAPI$ ls
asyncAPI.cu  Makefile  NsightEclipse.xml  readme.txt
me@comp:/usr/local/cuda-5.0/samples/0_Simple/asyncAPI$ sudo make
/usr/local/cuda-5.0/bin/nvcc -m64  -gencode arch=compute_10,code=sm_10 -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -I/usr/local/cuda-5.0/include -I. -I.. -I../../common/inc -o asyncAPI.o -c asyncAPI.cu
g++ -m64 -o asyncAPI asyncAPI.o -L/usr/local/cuda-5.0/lib64 -lcudart 
mkdir -p ../../bin/linux/release
cp asyncAPI ../../bin/linux/release
me@comp:/usr/local/cuda-5.0/samples/0_Simple/asyncAPI$ ls
asyncAPI  asyncAPI.cu  asyncAPI.o  Makefile  NsightEclipse.xml  readme.txt
me@comp:/usr/local/cuda-5.0/samples/0_Simple/asyncAPI$ ./asyncAPI
[./asyncAPI] - Starting...
GPU Device 0: "GeForce GT 630" with compute capability 2.1

CUDA device [GeForce GT 630]
time spent executing by the GPU: 32.30
time spent by CPU in CUDA calls: 0.04
CPU executed 114066 iterations while waiting for GPU to finish
me@comp:/usr/local/cuda-5.0/samples/0_Simple/asyncAPI$ 

here is related issue on StackOverflow.

thank you Soroosh129!

enter image description here

Best Answer

Installing the CUDA toolkit:

Downloading the CUDA toolkit:

First download the CUDA toolkit for Ubuntu 11.10 from here. Also there is a CUDA toolkit available from repos so maybe this will work but I haven't test it yet:

sudo apt-get install nvidia-cuda-toolkit

After you have downloaded the *.run file place it where you can find it easily, for example on the desktop.

Prerequisites:

Before installing the CUDA toolkit, first install freeglut3 as it is needed by CUDA Samples:

sudo apt-get install freeglut3 freeglut3-dev

Then it is recommended that you make a sim link to this version of freeglut just in case, but you might be OK if you don't have any other versions of freeglut:

First remove the existing sim link:

sudo rm /usr/lib/libglut.so

Then add your own sim link:

sudo ln -s /usr/lib/x86_64-linux-gnu/libglut.so.3 /usr/lib/libglut.so

Now it is necessary to remove existing gcc and g++ sim links because they already exist by default:

Remove the existing sim links:

sudo rm /usr/bin/cpp
sudo rm /usr/bin/gcc
sudo rm /usr/bin/g++

Then install gcc-4.6 and g++-4.6 (you have the option to install gcc 4.4 as well but in my opinion 4.6 is better):

sudo apt-get install gcc-4.6 g++-4.6

Then make a sim link to these compilers so that CUDA use this compiler as it's primary compiler:

sudo ln -s /usr/bin/cpp-4.6 /usr/bin/cpp
sudo ln -s /usr/bin/gcc-4.6 /usr/bin/gcc
sudo ln -s /usr/bin/g++-4.6 /usr/bin/g++

Installing the CUDA toolkit:

Press Ctrl + Alt + F1, this will take you to the first virtual terminal. Enter your user and password, and navigate to the folder which you've located the file, for example in case you have placed it on Desktop use:

cd ~/Desktop/

Then add execution permissions to the *.run file:

sudo chmod +x cudatoolkit*.run

Replace cudatoolkit*.run with the actual name of the downloaded file, in your case cuda_5.0.35_linux_64_ubuntu11.10-1.run .

Then stop the lightdm service:

sudo service lightdm stop

and finally run the CUDA toolkit:

sudo ./cudatoolkit*.run

again replace cudatoolkit*.run with the actual name. Then follow the onscreen instructions.

Note:

In case something goes wrong, even with gcc-4.4 you can remove it using:

sudo apt-get remove gcc-4.x g++-4.x

Replace x with your version.

Finally you can revert it back to the way it was by reverting the sim links to original:

sudo rm /usr/bin/cpp
sudo rm /usr/bin/gcc
sudo rm /usr/bin/g++
sudo ln -s /usr/bin/cpp-4.7 /usr/bin/cpp
sudo ln -s /usr/bin/gcc-4.7 /usr/bin/gcc
sudo ln -s /usr/bin/g++-4.7 /usr/bin/g++