
Configuring Ubuntu 8.10 for Coding for NVIDIA CUDA

I decided to seriously engage in distributed computing programming using this technology. I won’t tell in detail what it is like, I’ll only say that CUDA is designed to perform distributed computing not on the processor, but on the 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 the performance 180 (!) - Pentium 4 1.5 GHz Nuclear). 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 images and many effects are processed using CUDA. The technology is supported by video cards based on NVIDIA chips starting from Series 8 and newer, including, of course,
No sooner said than done. I will configure my ubuntu for this matter, 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 one 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 get started!
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, nothing will not work without it.
Great, continue! Now configure the compiler. To get started, download gcc and g ++ of the version we need (this is important - their version should be the same). The easiest way to do this is through Synaptic, finding gcc-4.1 and g ++ - 4.1 there, or you can write it in the console:
$ sudo apt-get install gcc-4.1 g++-4.1
You need to configure the system to use the compiler we need (see the ADF at the end!). This is done ridiculously simply: By the way, it is easy to return the "old" compiler to its place - just replace the 4.1 commands with 4.3 with the above commands. Well, of course, we need the CUDA components themselves - a video driver, toolkit and SDK. We take them from their home site . We indicate the system on 8.04; everything will work just fine.
$ 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++
Since we are going to use the latest version, we select packages for 2.1:
1. CUDA Driver - NVIDIA-Linux-x86-180.06-pkg1.run
(Thanks to Frosty , recently the version 180.22 driver was released, you can download it naturally from the official website . Procedure installation does not differ)
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 to drive (it is desirable that the path to them does not contain spaces or Cyrillic characters) and install chmod + x for all three packages . The preliminary stage is completed!
Actually installation.
First you need to install a video driver. It is set as standard: Press Ctrl + Alt + F1 and log in. Then: We are offered to download precompiled headers from the NVIDIA server. We refuse. Then we are offered to compile them under our core. We agree. We are waiting for a few seconds - and voila! The driver is installed. Now you can start the X-Server again: Now you need to correct one file a little: there you need to fix the line for this one
$ sudo -s -H
# /etc/init.d/gdm stop
# sh NVIDIA-Linux-x86-180.06-pkg1.run
# /etc/init.d/gdm start
$ sudo gedit /etc/default/linux-restricted-modules-common
DISABLED_MODULES = "nvidia nvidia_legacy nvidia_new"
Save and reboot. If the X server did not start, then you can simply restore the configuration file:
$ sudo cp /etc/X11/xorg.conf.backup /etc/X11/xorg.conf
and review your actions for errors.
Excellent! Now we will install the remaining two components: Paths (in the first case / usr / local / cuda and $ HOME / NVIDIA_CUDA_SDK in the second) are better left by default, to avoid. Now we dig a little environment variables. Ubuntu stores them in / etc / environment . You need to add to PATH : "/ usr / local / cuda: / usr / local / cuda / bin". And then it remains to edit one file: Add to the end
$ sudo ./cuda-linux-rel-nightly-2.1.1635-3065709.run
$ sudo ./cuda-sdk-linux-2.10.1126.1520-3141441.run
$ sudo gedit /etc/ld.so.conf
# NVIDIA CUDA v2.1 support
/ usr / local / cuda / lib
and type ldconfig :
$ sudo ldconfig
That's it, you can start to rejoice! Now we go to the SDK directory and try to collect examples. By the way, do not forget about the parameters of the make command . When compiling code for CUDA, they can be: - release configuration - make - debug configuration - make dbg = 1 - emurelease configuration - make emu = 1 - emudebug configuration - make emu = 1 dbg = 1 Do not forget that if on your computer there is no compatible video card - be sure to set the parameter emu = 1 .
$ cd ~/NVIDIA_CUDA_SDK
$ make
That's all, actually! Now, if everything went together correctly (if not, double-check whether the correct version of gcc and g ++ is needed), 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 flaws - 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 of changing the default compiler. Thanks for the amendment.
It’s more correct to do like this:
export CC = "gcc-4.1"
export CPP = "cpp-4.1"
export CXX = "g ++ - 4.1"
Write in ~ / .bashrc or simply set these variables before compiling the CUDA code.
APD2 : Option number 2, 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