Notification:
This tutorial is meant for installation of nVidia cuda toolkit 3.1 on openSuSE 11.3, and I have also added some specifics for Ubuntu Lucid Lynx. If you are using some other linux system or a different version of cuda toolkit, there might be some additional issues to cover. This tutorial covers the installation of cuda in gpu programming purposes, not gaming purposes.nVidia Cuda installation requirements
In order to install and use nVidia cuda, you will require an nVidia cuda enabled graphic card, or, alternatively, nVidia Tesla card.
To check whether your graphic card is cuda - enabled, open konsole, log in as root (sudo su) and type:
lspci | grep -i nvidia
The output should look something like:
0f:00.0 VGA compatible controller: nVidia Corporation G96 [Quadro FX 580] (rev a1)
nVidia Cuda installation resources
All the required files for installation of nVidia cuda can be acquired at the official nVidia cuda toolkit web site. The given link is for 3.1 version of toolkit, please google cuda toolkit if this is not the latest version.
Please find the Linux installation download area.
Make sure your version of Linux is supported. To find out your exact version of Linux, open Konsole and type:
uname -m && cat /etc/*release
The output should look something like this:
pitbull@ROMMEL:~> uname -m | cat /etc/*release
openSUSE 11.3 (x86_64)
VERSION = 11.3
Check if your OS is listed. If not, choose the closest OS to yours. At the time I am writing this blog, openSuSE 11.2 was supported, so I went with that. I also chose Ubuntu 9.10 files to install on Ubuntu 10.04.
Please make sure you choose the correct version of the files (32 or 64-bit). The x86_64 section in the output means you need 64-bit files, while i386 will mean you need 32-bit files.
The required files:
1. nVidia cuda C installation and verification on Linux systems - the getting started guide
2. Developer Drivers for Linux
3. CUDA toolkit
4. GPU computing SDK code samples
The Getting started guide is contained in this blog; however it would be good to have it in handy. This blog is written based on Developer Drivers for Linux version 256.40, CUDA toolkit v. 3.1 for openSuSE 11.2 and Ubuntu 9.10 and SDAK code samples for v. 3.1.
nVidia cuda installation procedure
The installation procedure is consisted of the following steps:
1. nVidia developer drivers installation
2. nVidia cuda toolkit installation
3. nVidia cuda SDK code samples installation
nVidia cuda device driver installation
In order to use cuda, you need to install special, cuda-enabled device drivers.
Please do not confuse the cuda developer driver with your ordinary nVidia graphic card drivers. If you already have an nVidia driver installed, and it's likely that you do, the cuda driver will replace it. To check your driver version, go to nvidia-settings (type this in the console or Kickoff), and find the driver version on the X server information tab.
Requirements:
In order to install the driver, you will need the following libraries/files already installed on your system:
- gcc++
- make
- kernel-devel
You can check whether they are installed using the Install/Remove software tool in YaST, or by Synaptic in Ubuntu. In order to install kernel-devel, you will need to enable the kernel source repository. Installation of kernel-develop files should also cover the make installation.
Installation procedure:
nVidia cuda device drivers need to be installed manually in the console mode. After downloading the appropriate drivers from the cuda toolkit web site, open the konsole, log in as root (sudo su) and type the following:
init 3
this will close X windows and get you in the console mode, where you'll need to log in. Assuming your driver file downloaded into /Downloads, do the following:
sudo su
cd /Downloads
sh ./devdriver_3.1_linux_64_256.40.run
This will start the driver installation. Answer "yes" to every question, including the 32-bit support. If the installation fails, you are either missing gcc++, make or kernel-develop, so install those first (eg zypper install kernel-devel).
After the installation is over, return to x windows by typing:
init 5
and, if necessary,
startx.
Note:
for Ubuntu, use
sudo /etc/init.d/gdm stop
or
gdm stop
(kdm for kubuntu) to close x windows, and
sudo /etc/init.d/gdm start
gdm start
(kdm for kubuntu) to start x windows.
To make sure the driver installation went through, you can re-check your driver version, using the nvidia-settings. The version number should coincide with the one in the filename of the downloaded cuda driver.
I suggest machine reboot after this step; even if it is not necessary. The reason is, if the driver for any reason isn't fully compatibile with your graphic card, it might not show before the reboot.
nVidia cuda toolkit installation
After the driver is installed, proceed to the cuda toolkit installation.
Open the konsole and go to the folder where your cuda toolkit files have downloaded. To install the toolkit you must log in as root, so do the following:
sudo su
sh ./cudatoolkit_3.1_linux_64_suse11.2.run
The installation will ask you for a cuda installation path, which I suggest you leave default (just hit enter).
After the installation, you will need to export two environment variables, PATH and LD_LIBRARY_PATH. To do so, you will need to add the following lines to the ~/.bashrc file which should be located in your Home directory.
Using , add the following lines to the end of the file for a 64-bit version: ~/.bashrc:
# profile for CUDA
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
or, for a 32-bit version: ~/.bashrc:
# profile for CUDA
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib:$LD_LIBRARY_PATH
then go to konsole, make sure you are not logged in as root, and restart bash by typing
bash
In order to check whether the variables are indeed exported and active, make sure you are not logged in as root and type:
echo $PATH
echo $LD_LIBRARY_PATH
The output should contain the /usr/local/cuda/bin for PATH and /usr/local/cuda/lib64 for LD_LIBRARY_PATH, respectfully. (Note: it will most probably contain other paths, as long as it contains these as well, it's OK.)
Note:
Do not export these variables manually! To export variables manually, you will be required to log in as root, which will export them for the root user only (meaning, if you execute echo $path as non-root, you will not see them in the output) and you will not be able to compile cuda code as non-root!
The following step is not necessary, however t's a good way to handle directly modifying the files in /usr/local/cuda.
groupadd cuda
gpasswd -a cuda
chgrp -R cuda /usr/local/cuda
chmod -R 775 /usr/local/cuda
nVidia cuda SDK installation
After you have installed the driver and the cuda toolkit, install the cuda SDK, in order to check whether your cuda installation actually works.
Requirements:
In order to install and compile the cuda SDK code samples, you will require certain libraries.
For openSuSE 11.3, open Install/Remove software and install the freeglut-dev or freeglut3-dev library.
Ubuntu Lucid will require quite a few more libraries (that's because openSuSE has them installed by default). Use apt-get or synaptic to make sure the following libraries are installed:
libxext-dev
libxi-dev
x11proto-xext-dev
(Fixes "cannot find -lXi" error)
libice-dev
libsm-dev
libxt-dev
libxmu-headers
libxmu-dev
(Fixes "cannot find -lXmu" error)
freeglut3-dev
libglut3-dev
(Fixes "cannot find -lglut" error)
Installation procedure:
After all the libraries have been installed, go to Konsole, make sure you are not logged in as root and type:
sh ./gpucomputingsdk_3.1_linux.run
When the installation is initiated, it will most likely verify the archive, and... hang.
Just hit the enter key.
The installation will ask for the cuda path; if you left it default (recommended), just accept and move on.
The installation will be set in /Home/user/NVIDIA_GPU_Computing_SDK.
nVidia cuda SDK compilation
Having installed the SDK, you need to compile the code examples.
Use the Konsole to go to the NVIDIA_GPU_Computing_SDK folder, then folder C and, while not logged in as root, run:
pitbull@ROMMEL:~/NVIDIA_GPU_Computing_SDK/C> make
The compilation procedure should start, and, if running the 64-bit version, you should encounter certain errors, eg.
SobelFilter_kernels.cu(53): error: calling a host function from a __device__/__global__ function is not allowed
SobelFilter_kernels.cu(53): error: calling a host function from a __device__/__global__ function is not allowed
2 errors detected in the compilation of "/tmp/tmpxft_000059a3_00000000-6_SobelFilter_kernels.compute_10.cpp1.ii".
Do not worry about these right now, but go to the NVIDIA_GPU_Computing_SDK/C/bin/linux/release folder, which should have been created during the compilation process, and run:
./deviceQuery
The output should look something like this:
pitbull@halder:~/NVIDIA_GPU_Computing_SDK/C/bin/linux/release> ./deviceQuery
./deviceQuery Starting...
CUDA Device Query (Runtime API) version (CUDART static linking)
There is 1 device supporting CUDA
Device 0: "GeForce GT 320M"
CUDA Driver Version: 3.10
CUDA Runtime Version: 3.10
CUDA Capability Major revision number: 1
CUDA Capability Minor revision number: 2
Total amount of global memory: 1073414144 bytes
Number of multiprocessors: 3
Number of cores: 24
Total amount of constant memory: 65536 bytes
Total amount of shared memory per block: 16384 bytes
Total number of registers available per block: 16384
Warp size: 32
Maximum number of threads per block: 512
Maximum sizes of each dimension of a block: 512 x 512 x 64
Maximum sizes of each dimension of a grid: 65535 x 65535 x 1
Maximum memory pitch: 2147483647 bytes
Texture alignment: 256 bytes
Clock rate: 1.10 GHz
Concurrent copy and execution: Yes
Run time limit on kernels: Yes
Integrated: No
Support host page-locked memory mapping: Yes
Compute mode: Default (multiple host threads can use this device simultaneously)
Concurrent kernel execution: No
Device has ECC support enabled: No
deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 3.10, CUDA Runtime Version = 3.10, NumDevs = 1, Device = GeForce GT 320M
PASSED
If the output looks like this, the installation has likely suceeded and everything's well.
Troubleshooting
1. The SDK installation and compilation issues - if you didn't get the deviceQuery file, check the whether environment variables have been correctly exported. Use echo $PATH and echo $:D_LIBRARY_PATH to check. Make sure you are not logged in as root while checking. Then re-start the compillation.
If you recieve the "cannot find -lXi", "cannot find -lXmu", "cannot find -lglut" errors, please check if all the aforementioned libraries are correctly installed.
2. The SDK compilation issues on 64-bit machines - this will prevent only certain examples from compiling, which is not critical for the cuda installation procedure. If you still wish to compile them, you will need to comment out certain lines in .h files. For details, please check here.
HARDWARE INFORMATION:
This tutorial was applied and verified on an HP ZX400 workstation featuring an nVidia Quadro FX 580, and an ASUS K70I notebook featuring an nVidia GeForce GT 320M graphic card.
SOFTWARE INFORMATION:
This tutorial was applied and verified on clean installations of openSuSE 11.3 and kUbuntu 10.04.
Nema komentara:
Objavi komentar