OpenCL on ATI Graphics Card in Ubuntu

I’m working on optimizing some OpenCV algorithms with OpenCL. I have an ATI graphics card and run Ubuntu 10.04. To familiarize myself with OpenCL I’m following enja’s Adventures in OpenCL tutorial. Unfortunately before I can get familiar with OpenCL, I have to install it! This was not terribly easy to figure out. Now that it’s done though, it’s a piece of cake. So I’m sharing what I had to do to get OpenCL running on my Ubuntu+ATI system.

Before OpenCL can utilize your graphics card, you need a driver which can give you that control. The new ATI Catalyst 10.7 driver is running great on my system. Don’t download it from there though, it’s a real pain to install. There is a script written to take care of it for you below.

Ubuntu 10.04 – i386

wget http://mathnathan.com/wp-content/uploads/2010/08/aticatalist10_7_i386.txt

chmod +x aticatalist10_7_i386.txt

./aticatalist10_7_i386.txt

Ubuntu 10.04 – amd64

wget http://mathnathan.com/wp-content/uploads/2010/08/aticatalist10_7_amd64.txt

chmod +x aticatalist10_7_amd64.txt

./aticatalist10_7_amd64.txt

Once the new driver is installed you want to hit a rebot and make sure it all went smoothly.

Next you need the ATI Stream SDK. This has all the OpenCL libraries. Once you’ve got it, extract it to a location of your choice using something like…

For 32 bit installation

cd /path/to/chosen/location
tar -xvzf /path/to/download/ati-stream-sdk-v2.2-lnx32.tgz

For 64 bit installation

cd /path/to/chosen/location
tar -xvzf /path/to/ati-stream-sdk-v2.2-lnx64.tgz

Now you need to set some environment variables. Add these to your .bashrc file.

32 bit Installation

vim ~/.bashrc

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH":/path/to/ati-stream-sdk-v2.2-lnx32
                                         /lib/x86/"
export LIBRARY_PATH=$LIBRARY_PATH":/path/to/ati-stream-sdk-v2.2-lnx32
                                         /lib/x86/"
export C_INCLUDE_PATH=$C_INCLUDE_PATH":/path/to/ati-stream-sdk-v2.2-lnx32
                                         /include/"

64 bit Installation

vim ~/.bashrc

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH":/path/to/ati-stream-sdk-v2.2-lnx64
                                          /lib/x86/"
export LIBRARY_PATH=$LIBRARY_PATH":/path/to/ati-stream-sdk-v2.2-lnx64
                                          /lib/x86/"
export C_INCLUDE_PATH=$C_INCLUDE_PATH":/path/to/ati-stream-sdk-v2.2-lnx64
                                          /include/"

Lastly you need to download the icd-registration.tgz file, and extract it to your /etc folder…

cd /
sudo tar xzf /path/to/icd-registration.tgz

Extracting it in the / directory automatically puts both atiocl32.icd, and atiocl64.icd in the /etc/OpenCL/vendors directory.

That’s all there was to it for me. After this I was able to compile enja’s programs and follow the rest of his tutorials. Good luck!

This entry was posted in OpenCL. Bookmark the permalink.

16 Responses to OpenCL on ATI Graphics Card in Ubuntu

  1. Pingback: Adventures in OpenCL: Part 1, Getting Started | enj

  2. Pingback: Adventures in OpenCL: Part 1.5, C++ Bindings | enj

  3. Victor says:

    This doesn’t look too painful, although am I correct in thinking that OpenCL is easier to install with Nvidia? I have traditionally went with Nvidia, simply because the support seems to be better, although after the last few releases of the driver, at least one of which caused some problems with GPU’s overheating, it gave me a little pause. Still, seems like Nvidia usually works better than ATI…

  4. Nathan Crock says:

    I’ve heard the same thing, Victor. I’ve got an ATI card on my laptop, which was my first device I chose to beef up with OpenCL. I’ve got an Nvidia card on my desktop and I plan to get OpenCL on there as well, so I’ll post about how that goes too!

  5. Julliano Silva says:

    I’m with problems when i’m installing the drivers for my card, it always givme an error to install the FGLRX. I’m always downloading the drivers from ATI website and following the tutorial to install this, but i never got sucess with this installation.. what i have to do?

  6. Nathan Crock says:

    Juliano,

    To use OpenCL you must have a video card driver capable of computing on the GPUs. If you have an ATI card, then your choice is to use the ATI Catalyst 10.7 driver. I would suggest not downloading it from the website, it is difficult. If you downloaded the script I suggest at the beginnning of my post it should fix all of your problems. If this doesn’t resolve your problem, let me know and we can look at a few other options.

    Good luck!

    Nathan

  7. Aelbery.Lee says:

    Nathan, thanks for you article. Should I uninstall the drive from “Hardware drivers” menu?

  8. Nathan Crock says:

    Aelbery,

    I didn’t remove it manually during my installation. The installer offered to remove it for me.

    Nathan

  9. Gabriel says:

    “I’m working on optimizing some OpenCV algorithms with OpenCL.” – How do you tell OpenCV to use your implementations?For example,a cvSmooth optimised for OpenCL.
    I am supposed to optimise an OpenCV filter for OpenCL, for a school project, so I would be very grateful if you could tell me about your progress in this matter

  10. Nathan Crock says:

    When you call an OpenCV function in your program, for it to work, you must have included a library containing it’s definition before you try to call it. so to call an OpenCV that is boosted with OpenCL, one must rewrite the algorithm in it’s respective header file. For instance if you wanted to optimize the cvAddWeighted() function you’d have to go into your cv.h header file and rewrite it and all of it’s dependencies.

    NOTE – This is not an easy thing to do at all. Various OpenCV functions rely on each other for functionality. So rewriting one function may mess up another.

    It’s a tedious process. I believe Willow Garage has an initiative to do exactly what you’re trying to do. Perhaps you can help them and seek more guidance at the same time.

    Good luck Gabriel

  11. MarkR says:

    Hi Nathan,

    I’m running Ubuntu 10.10 (64-bit) trying to get an HD 5870 working for a couple of distributed computing projects. I was directed here by a forum post and am hoping the info here can help me. Being very much the Linux newb I have a few questions about your procedure and would appreciate some help if you have the time.

    1) When installing the Stream SDK/OpenCL libraries, to what directory might someone typically extract the files? I downloaded the .tgz file to the desktop, but I figure there’s a better place to put it.

    2) When editing the .bashrc file, is there any place in particular to put the “export” statements? Can I just add them at the end? One right after the other?

    3) You say to extract the icd-registration file to “…your /etc folder.” Can you be a little more specific?

    4) Perhaps I should have asked this first, but are any steps unnecessary if I’m not a developer and just need the driver and OpenCL libraries installed. The GPU will be running programs that have already been developed and ready to use.

    Please excuse my newbness and thanks for any help you can provide.

    Mark

  12. Wow!! I appreciate what you’re performing! I require to relook at screen toaster! Informative and interesting post!!! maintain it up..

  13. Nathan Crock says:

    Hey Mark!

    Thanks for reading my post, and sorry for the late reply.

    4) The SDK should not be needed if you don’t plan to develop. It’s so easy to install however, I would suggest you do it. I posted this a few months ago, so getting all of the new stuff makes it more likely to work for you!

    1) When extracting the files, it really is immaterial where you put them. What matters is where you install them. Typically one will run ‘make install’. I personally have a library folder I call lib where I install all of the drivers and libraries I use to code.

    2) Adding your export statements to the bottom of the .bashrc is not a problem. If you find yourself editing it frequently, then where you put things might matter.

    3) If you execute the code in the box, it will automatically extract everything to the correct folders. (At least it did in Ubuntu 10.04) Where path/to/ represents where ever you downloaded the .tgz file.

    Good luck man

  14. Joren Six says:

    For the x64 version (for me at least) the paths you need to export in .bashrc should be:

    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH”:/opt/ati-stream-sdk-v2.3-lnx64/lib/x86_64/”
    export LIBRARY_PATH=$LIBRARY_PATH”:/opt/ati-stream-sdk-v2.3-lnx64/lib/x86_64/”
    export C_INCLUDE_PATH=$C_INCLUDE_PATH”:/opt/ati-stream-sdk-v2.3-lnx64/include/”

    So with “_64″ appended

  15. Nathan Crock says:

    Thanks for the feedback Joren! This post may be becoming a bit out of date. After I install Ubuntu 11.04 I plan to reinstall this and the other programs I’ve written tutorials on, I’ll keep your comment handy for when that time comes.

    Cheers!

  16. Carlos says:

    Thanks mate!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>