What is this? From this page you can use the Social Web links to save CUDA Riding to a social bookmarking site, or the E-mail form to send a link via e-mail.

Social Web

E-mail

E-mail It
April 22, 2009

CUDA Riding

Posted in: Open Source, Researches

CUDA is a parallel programming toolkit that utilizes GPU (Graphics Programming Unit). Searching a high performance computing platform for material computational research, I stumbled upon CUDA accelerated Molecular Modelling application, and have been longing to have a taste.

Hardware

To use cuda, we need a decent computer with 64 bit CPU (AMD Athlon, or Intel Xeon), and a CUDA supported GPU (must be NVIDIA). The CPU was pretty common, but I had to spend for about 2 weeks looking for the right GPU. I was a happy guy with a humble generic video card, but now, I learnt that there are three classes of NVIDIA GPU:

  • GeForce cards are consumer grade GPU, targetted for computer gaming.
  • Quadra cards are profesional grade GPU for serious applications like CAD.
  • Tesla are a special GPU for high performance computing. In fact, Tesla cannot be used for displaying graphics.

Quadra and Tesla lines are pretty expensive compared to the GeForce. So I narrowed the choices to the GeForce series. Oh well, there are various GeForce chips. Currently, the newest version are:

  • GeForce 9xxx series. The choices range from 9400 (about $50) to 9800 GTX+ (about $220)
  • GTS 2xx series. NVIDIA said GTS is for profesional. Currently there are only GTS 250 (about $200).
  • GTX 2xx series. This is for enthusiast. The lowest is GTX 260 (about $300) and the newest one is GTX 950 (About $600).

Just googling to find the reviews about each chips. Generaly, the performance and cost are propotional to the  the number of cores and memory. In the end, budget is the limit. So my current system is:

  • CPU : AMD Athlon 64 X2 Dual Core Processor 5600+
  • RAM : 4 GB
  • GPU : NVIDIA GTS 250, RAM 1 GB
  • Harddisk : SATA 250 GB
  • Network : GBE (2 ports)
  • Monitor : LCD 1440 x 900 (dual head)

Software

Without long googling, I chose the Linux Rocks Cluster distribution. The reasons:

  • This is a special distro for high performance computing.
  • It integrates many applications I really want to use, including Sun Grid Engine (used by our counter part at Osaka University Japan).
  • There are CUDA rool, provided by thir party.

The current version is Rock 5.1, which is based on CentOS 5.2. At the download page, there are several choices. Not wanting any problem, I downloaded the jumbo DVD version (more than 2 GB !) and burned it to the DVD. I followed the third party link there to download CUDA rools from Clustercorp.

OS Installation

Here we go … let’s the fun begin :D

Installation of Rock Linux was pretty straight forward. Just insert the DVD, boot the computer, and everything was friendly guided. The most difficult part was deciding the harddisk partitions. I went with:

  • sda1 : 1GB   swap
  • sda2 : 20 GB /
  • sda5 : 500 MB /tmp
  • sda6 : 4GB /var
  • sda7 : 200 GB /export

After about 1 hour of installation, Rocks 5.1 was up and running. I created a new login account for my self then started enjoying my first date with Rocks / CentOS (FYI, I’m a seasoned Slacker).

Graphics Configuration

I was not surprised to found out that the new system was using vesa driver for GUI. Slackware does that, always :D

So the first hunting is go to the NVIDIA download driver site. I got the NVIDIA-Linux-x86_64-180.22-pkg2.run file.To install it:

  • Go to the text console (press Alt-F1)
  • Login as root
  • Kill x-windows: init 2
  • Move to the folder that contains the downloaded driver : cd download/nvidia
  • Change mode to executable: chmod +x *.run
  • Run it : ./NVIDIA-Linux-x86_64-180.22-pkg2.run

Alas, the installer said that the current kernel was configured to use Zen virtual machine, which is not compatible with NVIDIA driver. So … we need a plain kernel. Where is it ? At Slackware, compiling a new kernel is pretty easy (for me). How to do that in CentOS ?

Turned out, I found it at /export/rocks/install/rolls/os/5.1/x86_64/RedHat/RPMS/ . Just install it from the command line:

  • rpm -i kernel-2.6.18-92.1.13.el5.x86_64.rpm
  • rpm -i kernel-devel-2.6.18-92.1.13.el5.x86_64.rpm

After rebooting, the NVIDIA installation was resumed. This time everything went well.

To use the nvidia driver, I simply edited the /etc/X11/xorg.conf (I’m a Slacker after all), changed just one line:

Section "Device"
        Identifier  "Card0"
        ## Driver      "vesa"
        Driver      "nvidia"
        VendorName  "Videocard Vendor"
        BoardName   "Unknown Board"
EndSection

However, calling startx was failed. The error message indicated that no device was found. Oh my. I exactly knew what was happening. GTS 250 was a new chip, and the diver could not support it yet.

Once again, google came to the rescue. It found a post in the nvidia forum, announcing the new release that supports GTS-250: NVIDIA-Linux-x86_64-180.51-pkg2.run. So I downloaded it, run it, then … I got the accelerated graphics. Just to check it, I run glxgears:

[root@hpc999 rocks]# glxgears
79179 frames in 5.0 seconds = 15835.775 FPS
85107 frames in 5.0 seconds = 17021.396 FPS
85422 frames in 5.0 seconds = 17084.264 FPS

Wohoo … I got to admit, I’ve never seen that much before. The best was only about 1200 FPS.

Dual Head Monitor

Well, I needed about 2 hours hacking this. To make it short, this is the complete working /etc/X11/xorg.conf (I was most helped by the same thing).

# Xorg configuration created by system-config-display
Section "ServerLayout"
    Identifier     "Multihead layout"
    Screen      0  "Screen0" LeftOf "Screen1"
    Screen      1  "Screen1" 0 0
    InputDevice    "Mouse0" "CorePointer"
    InputDevice    "Keyboard0" "CoreKeyboard"
    Option        "Xinerama" "on"
    Option        "Clone" "off"
EndSection
Section "Files"
    RgbPath      "/usr/share/X11/rgb"
    ModulePath   "/usr/lib64/xorg/modules"
    FontPath     "unix/:7100"
    FontPath     "built-ins"
EndSection
Section "Module"
    Load  "glx"
    Load  "vnc"
    Load  "record"
    Load  "dbe"
    Load  "extmod"
    Load  "xtrap"
EndSection
Section "ServerFlags"
    Option        "AIGLX" "on"
    Option        "Xinerama" "1"
EndSection
Section "InputDevice"
    Identifier  "Keyboard0"
    Driver      "kbd"
EndSection
Section "InputDevice"
    Identifier  "Mouse0"
    Driver      "mouse"
    Option        "Protocol" "auto"
    Option        "Device" "/dev/input/mice"
    Option        "ZAxisMapping" "4 5 6 7"
EndSection
Section "Monitor"
    Identifier   "Monitor0"
    VendorName   "ViewSonic"
    ModelName    "LCD Panel 1440x900"
    Option        "dpms"
EndSection
Section "Monitor"
    Identifier   "Monitor1"
    VendorName   "Monitor Vendor"
    ModelName    "LCD Panel 1440x900"
 ### Comment all HorizSync and VertSync values to use DDC:
    HorizSync    0.0 - 0.0
    VertRefresh  0.0 - 0.0
    Option        "dpms"
EndSection
Section "Device"
        ### Available Driver options are:-
        ### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
        ### <string>: "String", <freq>: "<f> Hz/kHz/MHz"
        ### [arg]: arg optional
        #Option     "ShadowFB"               # [<bool>]
        #Option     "DefaultRefresh"         # [<bool>]
        #Option     "ModeSetClearScreen"     # [<bool>]
    Identifier  "Card0"
    Driver      "nvidia"
    VendorName  "nVidia Corporation"
    BoardName   "Unknown Board"
EndSection
Section "Device"
    Identifier  "Card1"
    Driver      "nvidia"
    VendorName  "Videocard Vendor"
    BoardName   "nVidia Corporation Unknown device 0615"
    BusID       "PCI:6:0:0"
    Screen      1
EndSection
Section "Screen"
    Identifier "Screen0"
    Device     "Card0"
    Monitor    "Monitor0"
    DefaultDepth     24
    SubSection "Display"
        Viewport   0 0
        Depth     24
    EndSubSection
EndSection
Section "Screen"
    Identifier "Screen1"
    Device     "Card1"
    Monitor    "Monitor1"
    DefaultDepth     24
    SubSection "Display"
        Viewport   0 0
        Depth     24
        Modes    "1440x900"
    EndSubSection
EndSection
Section "Extensions"
    Option        "Composite" "Enable"
EndSection

Installing CUDA SDK

Yeah, the main course finally came. Please get the software from NVIDIA get CUDA site. Chose

  • OS : Linux 64 bit
  • Linux version : Redhat Enterprise Linux 5.x

Then download the CUDA toolkit and CUDA SDK samples. Install them right away:

  • chmod +x *.run
  • ./cudatoolkit_2.1_linux64_rhel5.2.run
  • ./cuda-sdk-linux-2.10.1215.2015-3233425.run

Compiling & Running CUDA Samples

Now, try the samples:

# cd ~/NVIDIA_CUDA_SDK/
# make

Oops … there was errors, saying the compiler cannot find libglut.
Now we need the help of CentOS yum package manager.

# export HTTP_PROXY="http://username:password@proxy.university.ac.id:8080"
# yum update
# yum search glut
# yum install freeglut
# yum install freeglut-devel

Here we go again …

# cd ~/NVIDIA_CUDA_SDK/
# make
#./bin/linux/release/fluidsGL

That was a cool first taste. There are some more examples at the ./bin/linux/release/ folder.


Return to: CUDA Riding