
I decided to get serious about programming distributed computing using this technology. I won’t tell you in detail what it is, I’ll just say that CUDA is designed for distributed computing not on a processor, but on a video card chip, which allows non-graphical calculations at a phenomenal speed (the performance of the GeForce 8800 GTX chip in mathematical calculations is approximately equal to 180 (!) - nuclear Pentium 4 1.5 GHz). This is mainly used to solve scientific problems, such as modeling various complex systems. By the way, this technology uses the latest version of Adobe Photoshop (CS4) - rendering of images and many effects are processed using CUDA. The technology is supported by video cards on NVIDIA chips from 8 series and newer, including, of course, Quadro and Tesla.
No sooner said than done. I will customize my ubuntu for this case, and at the same time I will tell about my experience;)
Note:1. Examples for CUDA can be safely written and compiled even on a computer without a supported video card, but they will work a hundred times slower than if it is available.
2. There is a known problem - CUDA has a bad relationship with the gcc-4.3 compiler, which is installed by default in Ubuntu 8.10, so you have to roll back to gcc-4.1. Details below :)
')
Let's start!
First, install the necessary libraries.
$ sudo apt-get install linux-headers-`uname -r` binutils pkg-config build-essential xserver-xorg-dev libc-dev
The most important thing here is libc-dev, without its presence nothing will work.
Great, continue! Now set up the compiler. First, download the gcc and g ++ version we need (this is important - their version must be the same). The easiest way to do this is through Synaptic, finding gcc-4.1 and g ++ - 4.1 there, but you can also write it to the console:
$ sudo apt-get install gcc-4.1 g++-4.1
We need to configure the system to use the compiler we need (see ADF at the end!). This is done ridiculously simple:
$ sudo rm -d /usr/bin/gcc
$ sudo ln -s /usr/bin/gcc-4.1 /usr/bin/gcc
$ sudo rm -d /usr/bin/g++
$ sudo ln -s /usr/bin/g++-4.1 /usr/bin/g++
By the way, it is easy to replace the “old” compiler - it is enough to replace 4.1 in the above commands with 4.3.
And, of course, we need the CUDA components themselves - the video driver, the toolkit and the SDK. We take them from the
home site . We specify the system 8.04, everything will work fine and so.
Since we are going to use the latest version - choose packages for 2.1:
1. CUDA Driver - NVIDIA-Linux-x86-180.06-pkg1.run
(Thanks to Comrade
Frosty - driver version 180.22 was recently released, you can download it, of course, from the
official site . The installation procedure is no different)
2. CUDA Toolkit - cuda-linux-rel-nightly-2.1.1635-3065709.run
3. CUDA SDK code samples - cuda-sdk-linux-2.10.1126.1520-3141441.run
Save them somewhere on the disk (it is desirable that the path to them does not contain spaces and Cyrillic characters) and install
chmod + x for all three packages. The preliminary stage is completed!
Actually installation.
First you need to put the video driver. It is set as standard:
$ sudo -s -H
# /etc/init.d/gdm stop
Hit Ctrl + Alt + F1 and log in. Then:
# sh NVIDIA-Linux-x86-180.06-pkg1.run
We are offered to download precompiled headers from the NVIDIA server. Refuse.
Then we are offered to compile them for our core. We agree.
We are waiting for a few seconds - and voila! The driver is installed.
Now you can run X-Server again:
# /etc/init.d/gdm start
Now we need to tweak one file a bit:
$ sudo gedit /etc/default/linux-restricted-modules-common
there you need to fix the line on this
DISABLED_MODULES = "nvidia nvidia_legacy nvidia_new"
Save and rebuy. If the X server does not start, you can simply restore the configuration file:
$ sudo cp /etc/X11/xorg.conf.backup /etc/X11/xorg.conf
and review their actions for errors.
Fine! Now install the remaining two components:
$ sudo ./cuda-linux-rel-nightly-2.1.1635-3065709.run
$ sudo ./cuda-sdk-linux-2.10.1126.1520-3141441.run
The paths (in the first case,
/ usr / local / cuda and
$ HOME / NVIDIA_CUDA_SDK in the second) should be left as default in order to avoid.
Now we dig a little environment variables. They are stored in
/ etc / environment in Ubuntu. You need to add to
PATH : "/ usr / local / cuda: / usr / local / cuda / bin". And then it remains to edit one file:
$ sudo gedit /etc/ld.so.conf
Add to the end
# NVIDIA CUDA v2.1 support
/ usr / local / cuda / lib
and type
ldconfig :
$ sudo ldconfig
Everything, it is possible to start to rejoice! Now we go to the SDK directory and try to collect examples.
$ cd ~/NVIDIA_CUDA_SDK
$ make
By the way, do not forget about the parameters of the command
make . When compiling code under CUDA, they may be:
- release configuration -
make- debug configuration -
make dbg = 1- emurelease configuration -
make emu = 1- emudebug configuration -
make emu = 1 dbg = 1Do not forget that if there is no compatible video card on your computer, you must set the parameter
emu = 1 .
That's all! Now, if everything is assembled correctly (if not, double-check if the version of gcc and g ++ is right), you can go to the
~ / NVIDIA_CUDA_SDK / bin / linux / release / directory and enjoy the examples. Personally, I liked
fluidsGL the most .
If there are any shortcomings - I will try to fix it. Good luck!
APD : I was asked at once by two comrades (
3dm and
timyr_lan ) to correct the way to change the default compiler. Thanks for the amendment.
Correct to do this:
export CC = "gcc-4.1"
export CPP = "cpp-4.1"
export CXX = "g ++ - 4.1"
Register in ~ / .bashrc or just set these variables before compiling CUDA code.
APD2 : Number 2 option, even simpler:
$ gedit ~/NVIDIA_CUDA_SDK/common/common.mk
# Compilers
NVCC: = $ (CUDA_INSTALL_PATH) / bin / nvcc.
CXX: = g ++ - 4.1
CC: = gcc-4.1
LINK: = g ++ - 4.1 -fPIC