Tuesday, May 18, 2010

Cuda 3.0 installation on Ubuntu Linux 10.04

I need to point out, that it is somewhat appalling the need to write a new tutorial for every time either a linux version or a product (pick your favourite) version is released. That said, I am off to provide the tutorial.

I had to read many tutorials and walkthroughs, as well as forum threads to succeed in the installation. So some parts might look very familiar!

First of all we will need to install the cuda graphics driver. Afterwards the cuda toolkit, followed by the cuda sdk. Finally we 'll install gcc 4.3 beacuse Cuda cannot cooperate with gcc 4.4 with which Ubuntu 10.04 ships. The linux version I am using is i386. I presume the instructions will work as well with x86_64 kernel.

Go to the official nvidia-CUDA download page:

Download the CUDA Toolkit and the CUDA SDK:

CUDA Toolkit for Ubuntu Linux 9.04 (32-bit)
GPU Computing SDK code samples and more

Installing the NVIDIA driver:
We'll need the latest cuda development driver available (195.xx), but first we'll uninstall the existing drivers.

1. Uninstall existing NVIDIA drivers and nvidia-glx.

(if you have enabled nvidia in system->administration->hardware drivers, then disable them first and possibly reboot)

sudo apt-get purge nvidia-*

2. Stop gdm service by running

sudo service gdm stop

3. Install drivers from nvidia repository

sudo add-apt-repository ppa:nvidia-vdpau/ppa
sudo apt-get update
sudo apt-get install nvidia-185-modaliases nvidia-glx-185 nvidia-settings
sudo nvidia-xconfig

4. Reboot and log back in.

5. Run


to verify that your driver version is at least 195. Look for the driver version in the window:
The 195.xx NVIDIA Driver for use with CUDA.

Installing the CUDA Toolkit:

After having installed the driver we now need to install the CUDA toolkit itself.

1. Run:

sudo sh cudatoolkit_3.0_linux_32_ubuntu9.04.run

2. Press enter to install at the default location.


3. Register the new library files:

sudo gedit /etc/ld.so.conf.d/cuda.conf &

and add the following to the empty file


Save the file and close gedit.
Then run:

sudo ldconfig

Create a link to the libcuda.so library:

cd /usr/lib
sudo ln -s nvidia-current/libcuda.so libcuda.so

Also add to the end of your ~/.bashrc file.

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

restart bash

Installing the CUDA SDK and Compiling the Example Programs

We will now install the CUDA SDK to our own home directory (we can experiment with the supplied demos):

1. Install SDK to the default location

sh gpucomputingsdk_3.0_linux.run

2. As CUDA does not yet work with GCC 4.4 we will have to install gcc-4.3:

sudo apt-get install gcc-4.3 g++-4.3 g++-4.4
sudo update-alternatives --remove-all gcc
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.3 43 --slave /usr/bin/g++ g++ /usr/bin/g++-4.3 --slave /usr/bin/gcov gcov /usr/bin/gcov-4.3
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 44 --slave /usr/bin/g++ g++ /usr/bin/g++-4.4 --slave /usr/bin/gcov gcov /usr/bin/gcov-4.4
sudo update-alternatives --config gcc ### choose gcc 4.3

3. Install CUDA SDK requirements

sudo apt-get install libglut3-dev libxi-dev libxmu-dev

4. Go to SDK source dir:

cd ~/NVIDIA_GPU_Computing_SDK/C$

5. You should now be able to compile everything by running


This should now compile all the examples in the SDK without errors.

Verify Installation

We can now verify that everything is working:

1. Run (from ~/NVIDIA_GPU_Computing_SDK/C):


On my machine I get the following output (depending on your harware, you output may be different. mine is a GeForce 8500 GT):

bin/linux/release/deviceQuery Starting...

CUDA Device Query (Runtime API) version (CUDART static linking)

There is 1 device supporting CUDA

Device 0: "GeForce 8500 GT"
CUDA Driver Version: 3.0
CUDA Runtime Version: 3.0
CUDA Capability Major revision number: 1
CUDA Capability Minor revision number: 1
Total amount of global memory: 536150016 bytes
Number of multiprocessors: 2
Number of cores: 16
Total amount of constant memory: 65536 bytes
Total amount of shared memory per block: 16384 bytes
Total number of registers available per block: 8192
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.57 GHz
Concurrent copy and execution: Yes
Run time limit on kernels: Yes
Integrated: No
Support host page-locked memory mapping: No
Compute mode: Default (multiple host threads can use this device simultaneously)

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 134566327, CUDA Runtime Version = 3.0, NumDevs = 1, Device = GeForce 8500 GT


Press to Quit...

That was it. It was a little hard, but it is worth the effort.

Let us only hope that we will not be obligated to write a new one for every release!!!

Monday, May 17, 2010

Load Oracle OCI driver on GlassFish (linux)

I had a really hard time finding the way to load the Oracle native libraries (Oracle runtime 10gR2 installation) on GlassFish (2.1.1) in linux (CentOS 5.4). Apparently GlassFish ignores the famous LD_LIBRARY_PATH variable for unknown reasons. I even tried setting it at the system wide profile. Nothing worked.

The java error was :
java.lang.UnsatisfiedLinkError: no ocijdbc10 in java.library.path

I wrote a small java class that loaded the oci driver successfully. I was sure the parameters were correct. GlassFish still ignored them. I realised that GlassFish was the problem. I tried setting -Djava.library.path. It still didn't work.

To make a long story short the answer is to set it at the GlassFish Admin GUI :
Configuration -->
server-config -->
JVM-settings -->
Tab: Path Settings -->
Native Library Path Prefix : /path/to/oracle/client/installation/lib

I hope this will save you the time I spent searching fruitlessly the internet.

p.s.Do not forget to give the Oracle native libraries the rx permissions to the FlassFish Admin user!

You can find me on fiverr for more personalized requests on any java app server configuration problem or java error that you encounter, with deliverance of less than a day (true!) and money back guarantee if not satisfied.