Install OpenCL on Debian, Ubuntu and Mint orderly

Libraries – can’t have enough

If you read different types of manuals how to compile OpenCL software on Linux, then you can get dizzy of all the LD-parameters. Also when installing the SDKs from AMD, Intel and NVIDIA, you get different locations for libraries, header-files, etc. Now GPGPU is old-fashioned and we go for heterogeneous programming, the chances get higher you will have more SDKs on your machine. Also if you want to keep it the way you have, reading this article gives you insight in what the design is after it all. Note that Intel’s drivers don’t give OpenCL support for their GPUs, but CPUs only.

As my mother said when I was young: “actually cleaning up is very simple”. I’m busy creating a PPA for this, but that will take some more time.

First the idea. For developers OpenCL consists of 5 parts:

  • GPUs-only: drivers with OpenCL-support
  • The OpenCL header-files
  • Vendor specific libraries (needed when using?-lOpenCL)
  • libOpenCL.so -> a special driver
  • An installable client driver

Currently GPU-drivers are always OpenCL-capable, so you only need to secure 4 steps. These are discussed below.

Please note that in recent 64-bit distributions there is not lib64, but only ‘lib’ and ‘lib32′. If that is the case for you, you can use the commands that are mentioned with 32-bit.

Header-files

update: A new package “opencl-headers” installs exactly these files for you.

No more?export CPPFLAGS=”-I/some_directory/opencl_sdk/include”?at last! All SDKs provide the OpenCL 1.1 header-files originated from Khronos (or should).

We only need to put all headers?found?from the Khronos-webpage in?/usr/include/CL/:

cd /usr/include

sudo mkdir CL

cd CL

sudo wget http://www.khronos.org/registry/cl/api/1.2/cl_d3d10.h?\
http://www.khronos.org/registry/cl/api/1.2/cl_d3d11.h?\
http://www.khronos.org/registry/cl/api/1.2/cl_dx9_media_sharing.h?\
http://www.khronos.org/registry/cl/api/1.2/cl_ext.h?\
http://www.khronos.org/registry/cl/api/1.2/cl_gl_ext.h?\
http://www.khronos.org/registry/cl/api/1.2/cl_gl.h?\
http://www.khronos.org/registry/cl/api/1.2/cl.h?\
http://www.khronos.org/registry/cl/api/1.2/cl_platform.h?\
http://www.khronos.org/registry/cl/api/1.2/opencl.h?\
http://www.khronos.org/registry/cl/api/1.2/cl.hpp ;

If you are on mobile, also get EGL:

sudo wget http://www.khronos.org/registry/cl/api/1.2/cl_egl.h

If you want?1.1?headers, do the following:

cd /usr/include

sudo mkdir CL

cd CL

sudo wget http://www.khronos.org/registry/cl/api/1.1/cl_d3d10.h?\
http://www.khronos.org/registry/cl/api/1.1/cl_ext.h?\
http://www.khronos.org/registry/cl/api/1.1/cl_gl_ext.h?\
http://www.khronos.org/registry/cl/api/1.1/cl_gl.h?\
http://www.khronos.org/registry/cl/api/1.1/cl.h?\
http://www.khronos.org/registry/cl/api/1.1/cl_platform.h?\
http://www.khronos.org/registry/cl/api/1.1/opencl.h?\
http://www.khronos.org/registry/cl/api/1.1/cl.hpp ;

sudo wget http://www.khronos.org/registry/cl/api/1.1/cl_egl.h

Now you can be sure you have the correct header-files.

Libaries

All vendors have their favourite spot to put their libraries; but actually a “just put your coat where you find a spot” is not the best to do. According to the best answer on?stackoverflow, the libraries should be in /usr/local/lib, but since these are shared libraries, Intel has found a good location: /usr/lib/OpenCL/vendors/. There was some discussion about “vendors”, but think of various wrapper-libaries, IBM’s?OpenCL Common Runtime, and such. So I agree with their choice.

Intel

update: Intel recently has completely changed the drivers for Linux. They now install in /opt/intel. Best is to copy all files from /opt/intel/opencl-1.2-x.x.xxxxxx to /usr/lib/OpenCL/vendors/intel to keep it orderly. If you choose not to, replace?/usr/lib/OpenCL/vendors/intel?with?/opt/intel/opencl-1.2-x.x.xxxxxx.

The?provided?rpm can be converted to deb and then works if?libnuma1?is installed:

apt-get install libnuma1
alien *.deb
dpkg -i *.deb

Though they’ve put their libraries at a nice spot, they made a little mistake. They put their libOpenCL.so in /usr/lib or /usr/lib64, instead of using a symbolic link. Below I discuss separately all around libOpenCL.so, since this is an important library. You need to copy it to the right directory. For 64 bit:

sudo cp /usr/lib64/libOpenCL.so /usr/lib64/OpenCL/vendors/intel/

For 32 bit systems:

sudo cp /usr/lib/libOpenCL.so /usr/lib/OpenCL/vendors/intel

It is very possible that if you installed another OpenCL SDK later, the library is lost. Not a real problem as explained later, but then you know.

To make the libraries available, I created opencl-vendor-intel.conf in /etc/ld.so.conf.d with the content (64 bit):

echo "/usr/lib64/OpenCL/vendors/intel" > /etc/ld.so.conf.d/opencl-vendor-intel.conf

In case you need to have 32-bit libraries too, you can add the location at the end of that file. And for 32 bit systems:

echo "/usr/lib/OpenCL/vendors/intel" > /etc/ld.so.conf.d/opencl-vendor-intel.conf

Then run

ldconfig

to start to using the new LD-location.

AMD

Edit:?as suggested by Steffen Moeller in the comments, installing the deb-files in?http://wiki.debian.org/ATIStream?is easier. Just check if the files are at the right place.

The AMD APP?Installer?let’s you choose where you want to put the SDK. Just put it somewhere you want the SDK to be. Go to the root of the AMD-APP-SDK and move the lib-directory to /usr/lib(64)/OpenCL/vendors/, for 64 bit systems:

mkdir -p /usr/lib64/OpenCL/vendors/amd/
mv lib/x86_64/* /usr/lib64/OpenCL/vendors/amd/

And for 32 bit systems:

mkdir -p /usr/lib/OpenCL/vendors/amd/
mv lib/x86/* /usr/lib/OpenCL/vendors/amd/

Then we need to add them to ld-config. For 64 bit:

echo "/usr/lib64/OpenCL/vendors/amd" > /etc/ld.so.conf.d/opencl-vendor-amd.conf

And for 32 bit systems:

echo "/usr/lib/OpenCL/vendors/amd" > /etc/ld.so.conf.d/opencl-vendor-amd.conf

Then run

ldconfig

NVIDIA

This is somewhat hard. You probably want to use CUDA too, so for that reason we leave the libraries in/usr/local/cuda/lib/?to avoid breaking software. Of course I prefer them to be tidied up under /usr/lib(64)/OpenCL/vendors/ but it is no use to make a symbolic link. Installer can be found?here.

Then we need to add them to ld-config, if you haven’t done that. For 64 bit:

echo "/usr/local/cuda/lib64" > /etc/ld.so.conf.d/opencl-vendor-nvidia.conf
echo "/usr/local/cuda/lib" >> /etc/ld.so.conf.d/opencl-vendor-nvidia.conf

For 32 bit:

echo "/usr/local/cuda/lib" > /etc/ld.so.conf.d/opencl-vendor-nvidia.conf

Then run

ldconfig

LibOpenCL.so

This library handles the selecting of the platforms (the vendors) and providing the correct libraries to the software needing the functionality. It is located under /usr/lib or /usr/lib64. You need to select which vendor you want to use. I personally think this driver should be?open sourced?and not from a specific vendor. Pick?one?(first line 64, second 32) out of these 6. But… from my own experience both AMD and Intel give you versions that work best with all 3 platforms, so I suggest you go for one of these.

Khronos open source

Get the “OpenCL 1.2 Installable Client Driver (ICD) Loader” from?http://www.khronos.org/registry/cl/?and make the project (needs cmake). In the bin-directory there will be libOpenCL.so.1.2. Remove all files startting with libOpenCL.so* and copy libOpenCL.so.1.2 to /usr/lib/.

sudo ln -s /usr/lib64/libOpenCL.so /usr/lib64/libOpenCL.so.1.2
sudo ln -s /usr/lib/libOpenCL.so /usr/lib/libOpenCL.so.1.2

I use this myself. Will add the binaries later.

AMD

sudo ln -s /usr/lib64/OpenCL/vendors/amd/libOpenCL.so /usr/lib64/libOpenCL.so.1.2
sudo ln -s /usr/lib/OpenCL/vendors/amd/libOpenCL.so /usr/lib/libOpenCL.so.1.2

NVIDIA

Strongly discouraged to use this libOpenCL-library!

sudo ln -s /usr/local/cuda/lib64/libOpenCL.so /usr/lib64/libOpenCL.so.1.1
sudo ln -s /usr/local/cuda/lib/libOpenCL.so /usr/lib/libOpenCL.so.1.1

Intel

sudo ln -s /usr/lib64/OpenCL/vendors/intel/libOpenCL.so /usr/lib64/libOpenCL.so.1.2
sudo ln -s /usr/lib/OpenCL/vendors/intel/libOpenCL.so /usr/lib/libOpenCL.so.1.2

Then we add libOpenCL.so.1, libOpenCL.so.1.0 and libOpenCL.so:

sudo ln -s /usr/lib64/libOpenCL.so.1.2 /usr/lib64/libOpenCL.so.1
sudo ln -s /usr/lib64/libOpenCL.so.1 /usr/lib64/libOpenCL.so
sudo ln -s /usr/lib/libOpenCL.so.1.2 /usr/lib/libOpenCL.so.1
sudo ln -s /usr/lib/libOpenCL.so.1 /usr/lib/libOpenCL.so

As libOpenCL.so.1.2 is/should be backwards compatible with libOpenCL.so.1.0 and libOpenCL.so.1.1, you can choose to make those symbolic links too. Only do this when you have wrongly linked software – link to libOpenCL.so.1 in your own software.

Be sure to link to libOpenCL.so.1.1 if you chose to use NVidia’s library.

Installable Client Drivers

important:?If you have chosen to leave the files in the original locations and skipped most of this tutorial, be sure to put the whole path and not only the filename in the icd-files.

If you list the platforms available, you actually list the ICDs. If you have written your own compiler, then you can easily add it without interfering with others. Like you can access an Intel CPU via both the AMD-ICD and Intel-ICD.

In /etc/OpenCL/vendor/ all ICDs need to be put. You’ll find them already here, or you have to create them. This is how they are provided now, but I omitted the library-location (which was in nvidia.icd), since it still gives errors if the ldconfig-steps where not done correctly.

sudo echo "libatiocl64.so" > /etc/OpenCL/vendors/atiocl64.icd
sudo echo "libatiocl32.so" > /etc/OpenCL/vendors/atiocl32.icdsudo echo "libintelocl.so" > /etc/OpenCL/vendors/intelocl.icdsudo echo "libcuda.so" > /etc/OpenCL/vendors/nvidia.icd

You can pick any name for the icd-files. AMD might replace ‘ati’ by ‘amd’ in their libraries, so if it stops working when updating, you know where to look.

Back to programming

When compiling a C or C++ program, you can keep your makefile simple. When the PPA with all this gets available, I’ll let you know via?Twitter,?Facebook. Tweet or like, if you support this blog!


本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/448607.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/448607.shtml
英文地址,請注明出處:http://en.pswp.cn/news/448607.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

linux7 配置mysql5.7字符集編碼

linux 安裝后 mysql5.7 字符集默認是拉丁,不能存儲中文,修改步驟如下: 在 vim /etc/mysql/my.cnf 修改配置文件 在[mysqld] 下添加如下配置 character-set-serverutf8 init_connectSET NAMES utf8 重啟mysql服務 systemctl restart mysqld.…

解決:java.io.IOException: invalid constant type: 15

前些天發現了一個巨牛的人工智能學習網站,通俗易懂,風趣幽默,忍不住分享一下給大家。點擊跳轉到教程。 啟動 dubbo 服務報錯: java.io.IOException: invalid constant type: 15 我的情況是項目本身 是用的1.7 。而我自己用的…

liunx常用命令筆記

安裝軟件教程 linux安裝java:https://www.cnblogs.com/lamp01/p/8932740.html linux安裝mysql:https://www.cnblogs.com/daemon-/p/9009360.html linux安裝redis:https://blog.csdn.net/qq_30764991/article/details/81564652 linux安裝nginx…

李洋瘋狂C語言之編程實現統計某年某月份的天數

今天的題目:編程實現統計某年某月的天數 例如: 輸入:2017.7 輸出:31天 先附上我自己想的方法,由于幾個功能放一起太繁瑣,于是我想把他們分為三個函數,分別來實現這個功能: #incl…

MQ 之 RocketMQ

前些天發現了一個巨牛的人工智能學習網站,通俗易懂,風趣幽默,忍不住分享一下給大家。點擊跳轉到教程。 RocketMQ 是出自 A 公司的開源產品,用 Java 語言實現,在設計時參考了 Kafka,并做出了自己的一些改進…

好久沒敲代碼了(強行補上今天的博客。。。)

流水賬日記(哈哈) 今天沒課,早上好好的睡了個懶覺(雖然還是很困- -); 哥幾個把昨天買的排骨洗了做了個排骨湯,雖然不如家里做的好吃,但對此時的我們來說已經是美味了,晚…

Ubuntu下使用AMD APP編寫OpenCL程序

對于Ubuntu或其近親(Lubuntu、Kubuntu、Mint等)編寫OpenCL程序也不會太難。由于本例用的是AMD APP SDK,因此需要AMD的GPU以及相關驅動。首先,去AMD官網下載GPU驅動——AMD Catalyst。如果你用的是APU并且還有一塊獨立顯卡的話&…

jdk的安裝與配置

Linux一、安裝JDK 從sun網站上直接下載JDK:http://java.sun.com/j2se/1.4.2/download.html提供了兩個下載j2re-1_4_2_10-linux-i586.bin 13.75 MB, j2re-1_4_2_10-linux-i586-rpm.bin 13.27 MB:1、RPM in self-extracting file (j2re-1_4_2_10-linux…

李洋瘋狂C語言之n個人報數,報到3的退出,最后留在場上的是原來的第幾位(約瑟夫環)

今天老師布置了個題目&#xff0c;約瑟夫環&#xff0c;俗稱猴子選大王。n個人報數&#xff0c;報到3的退出&#xff0c;最后留在場上的時原來的第幾位 #include <stdio.h>int main() {int i, n, q, p 0; //計數 i ,人數 n ,報數 p ,場上人數 qprintf ("input…

搭建Vue腳手架(vue-cli)并創建一個項目

1、 安裝nodejs環境 官網下載&#xff1a;https://nodejs.org/en/download/ 一直默認就行&#xff0c;路徑可以改變但要記得到 安裝完成后cmd&#xff0c;輸入node -v ,npm -v 如果能看到node和npm的版本號了&#xff0c;說明已經安裝成功 2、安裝vue-cli 有npm和cnpm兩種方式…

NPM 使用介紹

前些天發現了一個巨牛的人工智能學習網站&#xff0c;通俗易懂&#xff0c;風趣幽默&#xff0c;忍不住分享一下給大家。點擊跳轉到教程。 NPM是隨同NodeJS一起安裝的包管理工具&#xff0c;能解決NodeJS代碼部署上的很多問題&#xff0c;常見的使用場景有以下幾種&#xff1a…

人生致命的八個經典問題

問題一&#xff1a;如果你家附近有一家餐廳&#xff0c;東西又貴又難吃&#xff0c;桌上還爬著蟑螂&#xff0c;你會因為它很近很方便&#xff0c;就一而再、再而三地光臨嗎&#xff1f; 回答&#xff1a;你一定會說&#xff0c;這是什么爛問題&#xff0c;誰那么笨&#xff0c…

RabbitMQ學習總結(5)——發布和訂閱實例詳解

2019獨角獸企業重金招聘Python工程師標準>>> 一、Publish/Subscribe&#xff08;發布/訂閱&#xff09;&#xff08;using the Java Client&#xff09; 在前面的教程中,我們創建了一個work Queue&#xff08;工作隊列&#xff09;。工作隊列背后的假設是每個任務是…

iOS有哪些數據類型/基本數據類型?

簡述 本文主要探究使用OC作為iOS開發語言時&#xff0c;我們能使用哪些數據類型。 一切類型始于C。 C語言的類型 基本數據類型&#xff1a; 基本數據類型&#xff08;fundamental data types&#xff09;也叫原始數據類型&#xff08;primitive data types&#xff09; 整型、字…

李洋瘋狂C語言之將”you are come from shanghai ”倒置為”shanghai from come are you”,將句子中的單詞位置倒置,而不改變單詞內部結構

題目: 編寫一個C函數,將”you are come from shanghai ”倒置為”shanghai from come are you”,及將句子中的單詞位置倒置,而不改變單詞內部結構 #include <stdio.h> #include <string.h> void change(char *p1, char *p2); //函數聲明 int main() {char str[] …

馬桶怎么清洗才干凈無異味?

方法/步驟 在馬桶水箱中一定要放上潔廁寶&#xff1a; 潔廁寶里面含有多種去除馬桶中雜質以及異味的功能&#xff0c;另外它還帶有香香的味道&#xff0c;我們一按沖馬桶的按鈕&#xff0c;放出來的總是藍色的水&#xff0c;十分的美觀和好看&#xff0c;但是這并不是花瓶般的作…

白話解說:阻塞和非阻塞,同步和異步

阻塞和非阻塞&#xff0c;同步和異步是node.js里經常遇到的詞匯&#xff0c;舉例說明&#xff1a; 我要看足球比賽&#xff0c;但是媽媽叫我燒水&#xff0c;電視機在客廳&#xff0c;燒水要在廚房。家里有2個水壺&#xff0c;一個是普通的水壺&#xff0c;另一個是水開了會叫的…

蘇嵌點滴(一)

來蘇嵌也有12天了&#xff0c;也漸漸開始習慣這樣的生活&#xff0c;每天睜眼到閉眼&#xff0c;全都是代碼。每天都得學習很多新的知識&#xff0c;C語言學到現在也學得差不多了&#xff0c;還有明天一天課。 指針、數組這些C語言中的重點&#xff0c;還是需要一點時間消化的…

Mysql學習總結(8)——MySql基本查詢、連接查詢、子查詢、正則表達查詢講解...

2019獨角獸企業重金招聘Python工程師標準>>> 查詢數據指從數據庫中獲取所需要的數據。查詢數據是數據庫操作中最常用&#xff0c;也是最重要的操作。用戶可以根據自己對數據的需求&#xff0c;使用不同的查詢方式。通過不同的查詢方式&#xff0c;可以獲得不同的數據…

安裝OpenCL和AMD驅動程序

我們將安裝AMD OpenCL軟件開發工具包&#xff08;SDK&#xff09;和AMD驅動程序。 userubuntu:~$ mkdir AMD-APP-SDK-v2.5-lnx64 userubuntu:~$ cd AMD-APP-SDK-v2.5-lnx64/ userubuntu:~$ wgethttp://developer.amd.com/Downloads/AMD-APP-SDK-v2.5-lnx64.tgz userubuntu:~$ t…