Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
opencl [2015/06/22 20:50]
slackermedia
opencl [2021/06/03 19:48] (current)
Line 1: Line 1:
-[[{arrowp.png|border:​0;​background:​none;​width:​0;​display:​inline-block;​position:​absolute;​top:​0;​left:​0;​}natron|]] +======OpenCL======
- +
-[[{arrown.png|border:​0;​background:​none;​width:​0;​display:​inline-block;​position:​absolute;​top:​0;​margin-left:​2.5em;​}opencolorio|]]+
  
 OpenCL is an open framework that enables a computer to recruit all manner of other computational devices (such as a GPU and additional CPUs) to distribute a workload. Depending on the hardware you have available, OpenCL can speed up graphics processing by orders of magnitude. OpenCL is an open framework that enables a computer to recruit all manner of other computational devices (such as a GPU and additional CPUs) to distribute a workload. Depending on the hardware you have available, OpenCL can speed up graphics processing by orders of magnitude.
Line 31: Line 29:
 </​WRAP>​ </​WRAP>​
  
 +</​WRAP>​
 +
 +===== Pre-Requisites =====
 +
 +Before attempting to get OpenCL up and running, get the specs of your system with ''​cpuinfo''​ and ''​lspci'':​
 +
 +<​code>​
 +$ lspci | grep VGA
 +[...] NVIDIA [Quadro 5000] (rev c2)
 +</​code>​
 +
 +Refer to product documentation to determine whether your GPU is OpenCL capable.
 +
 +<​code>​
 +$ egrep sse[3456] /​proc/​cpuinfo
 +flags : fpu vme [...] sse3 [...] sse4_1 [...]
 +</​code>​
 +
 +If your terminal returns anything, then it is OpenCL capable.
 +
 +==== Installing OpenCL ====
 +
 +The OpenCL framework consists of an OpenCL library providing the actual API (the programming bits that applications seeking to use OpenCL will actually //use//), device drivers (to drive the GPU or other OpenCL capable device), and the OpenCL code compiler and header files (needed to build applications with OpenCL enabled).
 +
 +Here is what you need to do to get them, and to enable them:
 +
 +**Headers**
 +
 +
 +Whether you intend to develop applications using OpenCL or not, in order to build and install OpenCL-capable applications,​ you need the OpenCL header files.
 +
 +OpenCL headers are available from [[http://​slackbuilds.org]].
 +
 +
 +**OpenCL Library**
 +
 +
 +OpenCL libraries (the ''​.so''​ files in ''/​usr/​lib*''​) mainly come from Nvidia and AMD (other vendors have implementations,​ but these are the most-used libs, since these are the two most common high-end graphic cards). OpenCL being an open standard, it does not actually matter which library you use. In fact, the OpenCL library you end up with will most likely be dictated by the GPU you have in your computer; the OpenCL library will come along with the driver that you install.
 +
 +Your OpenCL driver of choice is (ie, ''​libcl''​ or ''​libopencl''​) loads an **Installable Client Driver** (defined by an ''​.icd''​ file). The ICD Loader enables an OpenCL application to access all platforms and all devices present in the system, so if you have devices by more than one vendor in your computer (and it's likely that you do), it's to your advantage to define them all.
 +
 +Therefore, to get the OpenCL library, install a driver for your graphics card and, if available, for your CPU:
 +
 +  * Nvidia drivers are available from [[http://​slackbuilds.org]] or directly from Nvidia. ​
 +  * AMD drivers, such as they are, are available from [[http://​amd.com]].
 +  * For Intel CPUs and graphic chips, generic drivers come bundled with the Intel Media Server Studio package. This requires registration with Intel and an email verification containing the actual download link. One downloaded, the libraries are located in ''​MediaServerStudioEssentials*/​SDK20*ProductionX.Y*/​Generic''​. For more specific device drivers, see [[https://​software.intel.com/​en-us/​articles/​opencl-drivers]].
 +
 +
 +
 +**Installable Client Drivers (ICD)**
 +
 +
 +It's possible to install multiple vendor-specific implementations of OpenCL technology on the same machine, at the same time. 
 +
 +After you have installed your primary OpenCL driver, you should find that an ''​.icd''​ file exists in ''/​etc/​OpenCL/​vendors/''​. The contents of the ''​.icd''​ files is straightforward:​
 +
 +<​code>​
 +$ file /​etc/​OpenCL/​vendors/​nvidia.icd
 +/​etc/​OpenCL/​vendors/​nvidia.icd:​ ASCII text
 +$ cat /​etc/​OpenCL/​vendors/​nvidia.icd
 +libnvidia-opencl.so.1
 +</​code>​
 +
 +It's just a pointer to the vendor library for actual OpenCL functionality.
 +
 +Install OpenCL drivers for each major vendor whose devices you want to recruit into your OpenCL pool. The common drivers and libraries are:
 +
 +  * ATI Stream SDK &#47; libatiocl"​$ARCH"​.so
 +  * Nvidia &#47; libnvidia-opencl.so
 +  * Intel &#47; libintelocl.so
 +
 +
 +===== Nvidia-modprobe =====
 +
 +If you are using a primarily Nvidia environment,​ you must invoke the ''​nvidia-modprobe''​ command:
 +
 +As root, open ''/​etc/​rc.d/​rc.local''​ in a text editor:
 +
 +<​code>​
 +$kdesu -c 'emacs /​etc/​rc.d/​rc.local'​
 +</​code>​
 +
 +And add a line to load in the OpenCL modules. ​
 +
 +<​code>​
 +/​usr/​bin/​nvidia-modprobe -c 0 -u
 +</​code>​
 +
 +If you are using AMD or Intel, there is no dedicated command to load any components. The libraries are called upon when needed.
 +
 +===== Mixed Environments =====
 +
 +If your goal is to create an array of graphic cards and make a GPU-driven render farm, it's easiest to keep your environment as homogeneous as possible. Mixing AMD and Nvidia GPUs leads to competing drivers sometimes to the point of a non-booting system. It's //​possible//​ to use a mixed environment,​ but it make things far more complex.
 +
 +===== OpenCL Apps =====
 +
 +Not all applications use OpenCL, and not all applications would benefit from OpenCL if they did use it. Currently, the two most significant OpenCL applications are Blender, LuxRender, and GIMP (with Krita up-and-coming),​ but this list is sure to grow.
 +
 +Blender and LuxRender will utilise OpenCL when it is available, so no further configuration is necessary.
 +
 +To use OpenCL in GIMP, launch GIMP with this command:
 +
 +<​code>​
 +GEGL_USE_OPENCL=yes gimp&
 +</​code>​
 +
 +The actual impact of OpenCL will depend largely on what kind of tasks you are performing, and what kind of system you have.
 +
 +<WRAP tip>
 +**See Also** \\
 +[[render|Render Farming]]
 +</​WRAP>​
 +
 +<WRAP centeralign>​
 +<wrap fa>​[[obs|R]]</​wrap>​ <wrap fa>​[[start|S]]</​wrap>​ <wrap fa>​[[opencolorio|Q]]</​wrap>​
 </​WRAP>​ </​WRAP>​