# How to set up OpenCL in Linux

You:

• Want to install OpenCL to compute on CPUs and GPUs This guide:

• shows you how to easily set up a functional OpenCL environment on just about any Linux box [[!toc ]]

## Overview

To use OpenCL, you need three things: libOpenCL.so -- the "ICD loader" : This library dispatches your OpenCL calls to OpenCL implementations. It is what you link into your OpenCL-using program (or into PyOpenCL, as the case may be). Individual implementations are called ICDs ("Installable Client Drivers").

/etc/OpenCL/vendors/*.icd -- the "ICD registry" : These files tell the ICD loader what OpenCL implementations (ICDs) are installed on your machine. There's one for each ICD. Each file is a one-line text file containing the name of the dynamic library (aka shared object, aka ".so" file) containing the implementation. The single line may either be the full absolute path or just the file name, in which case the dynamic linker must be able to find that file--perhaps with the help of setting the LD_LIBRARY_PATH environment variable. The names of the .icd files themselves are arbitrary, but they must have a file extension of .icd.

One or more OpenCL implementations -- the "ICDs" : These are dynamic libraries pointed to by the .icd files, plus perhaps a few supporting files. They may reside anywhere on your file system. You can (and likely want to) have more than one installed.

Each implementation typically ships all of these components. They will tend to step on each other's feet if you're not careful. Avoiding such accidents is what this guide is about.