This post is meant as an introduction on how to do some serious number crunching on the GPU using Linux and the CUDA programming framework. Sometimes, a problem for new programmers is how to properly set up their programming tools. The reason for this is that the available information is usually written by and for the experts, thus creating a very steep learning curve for the “newcomers”. Furthermore, a very common problem on Linux is to install the proper graphics card driver, as the bundled driver usually lacks the cuda driver. As anyone who has gone through the process knows, updating the graphics card driver on Linux can be “tricky” and sometimes even daunting. I had a similar experience with various Linux distros recently, until I came across Porteus.
To quote from the official website:
Porteus has several advantages:
It is based primarily on Slackware linux, the oldest and more stable linux distro, and secondarily on Slax linux. This also means that you can use the vast Slackware and Slax repositories (some caveats apply though).
It is a live distro that can be installed on a USB stick or external hard drive, which means that you can test the whole set-up with out fear of messing your PC.
It has a fast growing an vibrant community ready to help at the official forum
Programs come in the form of modules and in order to install them you just copy them in the /modules folder.
I will start from the very basics, ie how to set up everything (including Porteus) and all the way to compiling some simple examples. I will keep updating this post as needed. However, please keep in mind that I am not an expert in CUDA, so I will not be able to answer questions related to CUDA programming itself (use the NVIDIA forum instead).
Download the necessary files
Installation of the framework and the SDK
Build the shared libs
Do some tests
Have some fun! [/b]
I have done all my tests on an HP dv8-1190eo laptop running Porteusx64, 8GB RAM, Geforce 230M GT graphics card.
i) A laptop/PC running Porteus
Follow the very simple instructions to install Porteus:
More details can be found at:
For questions on Porteus, please don’t use this thread but visit the official Porteus forum.
ii) A supported NVIDIA graphics card. The x64 version of the driver can be found at:
To install the driver just copy it in the /modules folder. Really!
If you are not sure whether your card is supported, a quick way to check is to see if your laptop or PC has an NVIDIA sticker that says something like: “GEFORCE with CUDA” or just go to
http://www.nvidia.com/object/cuda_gpus.html and check if your card is supported.
2) Download the necessary files
(take care to download the x64 versions where available)
You will need the following files freely available from NVIDIA’s site:
The NVIDIA driver found at the Porteus site includes the CUDA driver, so you only need to download the Toolkit and the SDK.
i) Grab the CUDA toolkit (I know it’s the Fedora version, but it works OK):
ii) Grab the SDK:
The SDK contains tons of examples and it is vital if you want to do any serious work.
iii) Grab any extra Guides or Libraries you want. The GPU-accelerated LAPACK libraries could be useful but I will cover that in a future post.
3) Installation of the framework and the SDK
In order to install the files open a console in the folder where you downloaded them and type:
i) sh ./cudatoolkit_3.2.16_linux_64_fedora13.run
The command above will install the toolkit. When prompted choose the recommended path. You can of course choose a different one, but that complicates things
ii) sh ./gpucomputingsdk_3.2.16_linux.run
The command above will install the SDK. Again when prompted choose the recommended path. You might get a couple of warnings during the installation (I did) but everything should be OK.
iii) Go to your .bash_profile file (it is hidden in your Home folder) and add the following lines:
and yes there is some redundancy but not including some of the lines gave me some errors during the tests. Anyway, remember to change lib64 to just lib if you have the x32 version.
4) Build the shared and common libs
i) After the reboot, go to:
Type make to build the shared libs. These are not necessary to use CUDA, but they are required for the examples. The result should be a lib: libshrutil_x86_64.a in the lib folder.
ii) Go to:
Type make to build the common libs. Again, this is not necessary for CUDA, just the examples. The result should be a lib: libcutil_x86_64.a in the lib folder.
5) Do some tests
The folder /root/NVIDIA_GPU_Computing_SDK/C/src/ contains the examples.
So, go to the folder named bandwidthTest/ and in a console type make. This will build the example and if no errors have occured a binary will have been created in /root/NVIDIA_GPU_Computing_SDK/C/bin/linux/release/ , so go to this folder and run the binary bandwidthTest. The result should be something like:
The critical part is where is says PASSED which obviously means that everything is working OK.
6) Have some fun!
Try compiling some of the other examples, but keep in mind that some of them have extra requirements, like the OpenGL lib etc.