How to Install OpenCL on Ubuntu for GPU Compute Nodes

To install OpenCL on Ubuntu you need the ICD loader plus your GPU vendor's runtime. Here is how to set up each and verify every node's devices with clinfo.

How to Install OpenCL on Ubuntu for GPU Compute Nodes
Written by TechnoLynx Published on 11 Jul 2026

Installing OpenCL on Ubuntu takes two separate pieces. The first is the ICD loader, packaged as ocl-icd-libopencl1, which provides the libOpenCL.so your programs link against. The second is a vendor runtime for the GPU that is physically in the machine. The runtime is registered through a .icd file in /etc/OpenCL/vendors, and the loader reads that directory to find it. After both are in, run clinfo and check that the platform and device counts match the hardware, because if clinfo finds no platform or device, chances are high that no other OpenCL application on that node will run either. On a GPU compute node that check is the step that matters, since a node can build against the loader and still lack a runtime.

How Do You Install OpenCL on Ubuntu, and What Does That Mean in Practice?

In practice, an OpenCL install on Ubuntu means picking the vendor stack that matches the GPU, making sure the loader is present, and confirming the result before trusting it. Ubuntu does not choose a runtime for you, and on its own the loader is a dispatcher with nothing to dispatch to: libOpenCL.so “does not contain any OpenCL implementation itself”, in the words of its Debian manual page.

The order we would follow on a fresh node looks like this:

  1. Install the GPU driver and the vendor’s OpenCL runtime (the per-vendor commands are below).
  2. Make sure the loader package ocl-icd-libopencl1 is installed. Intel’s install procedure names it as an example dependency to install if the runtime packages hit installation problems.
  3. Install clinfo and list what the loader can see.
  4. Compare that list with the GPUs you know are in the chassis.
sudo apt install ocl-icd-libopencl1 clinfo
ls /etc/OpenCL/vendors     # one .icd file per registered runtime
clinfo -l                  # platforms and devices, as a short tree

Ordering matters less than the last step. Packages can install cleanly while leaving the node without a usable device, and a mismatch between what the node should see and what it does see only shows up when you go and look.

Why Do I Need Both the ICD Loader and a Vendor Runtime?

The ICD loader and the vendor runtime do different jobs, and running an OpenCL application needs both. The Khronos ICD Loader README describes the mechanism: it lets developers build applications against a loader “rather than linking their applications against a specific OpenCL implementation”. The loader’s job is to export the OpenCL API entry points, enumerate the implementations installed, and forward each call to the right one. It contains no implementation of its own, so you have to install one for your device that supports the cl_khr_icd extension.

Discovery works as the Khronos cl_khr_icd specification describes. On Linux the loader scans /etc/OpenCL/vendors, reads each file as one line of text naming the vendor library (an absolute path or just a file name), and opens that library with dlopen(). The ocl-icd loader loads files whose names end in .icd. Once a library loads, the loader looks up clIcdGetPlatformIDsKHR, clGetPlatformInfo and clGetExtensionFunctionAddress, and if any of those three is missing it closes the library and ignores it.

The split exists because one machine can hold several OpenCL-capable devices and so several runtimes, with the loader acting as the vendor-neutral layer that presents them all through a single API. Intel’s compute-runtime project likewise states that OpenCL applications should link with the ICD loader library. A binary linked that way is not tied to a specific OpenCL implementation. If you want the wider picture of where OpenCL sits next to CUDA, see our explainer on what OpenCL is and how cross-vendor compute works.

Which Packages Install OpenCL on Ubuntu for NVIDIA, AMD and Intel GPUs?

Each vendor ships its OpenCL runtime differently. The generic loader is the same in every case, and the runtime is specific to your device.

GPU vendor Runtime route on Ubuntu What to check afterwards
NVIDIA sudo ubuntu-drivers install --gpgpu, ideally with a -server (Enterprise Ready Driver) branch on compute nodes /dev/nvidia* exists with the right permissions
AMD amdgpu-install with the opencl use case (ROCr-based OpenCL, Vega or later); openclsdk adds development files The GPU is on ROCm’s supported list
Intel apt-get install intel-opencl-icd (Compute Runtime, “NEO”) The user can access /dev/dri/renderD*
Any ocl-icd-libopencl1 loader plus clinfo Every expected device is listed

NVIDIA

Ubuntu’s server documentation separates two kinds of NVIDIA driver. Unified Driver Architecture drivers are recommended for generic desktop use. Enterprise Ready Drivers, which carry the -server suffix, are recommended for servers and compute work. sudo ubuntu-drivers install --gpgpu picks the best match automatically. To pin a branch, list the options with ubuntu-drivers list --gpgpu and install one explicitly, for example nvidia:535-server. For a fleet, we would pin the driver branch rather than rely on automatic detection, so that every node reports the same platform version.

AMD

AMD’s amdgpu-install tool installs and updates AMDGPU, ROCm and ROCm components, and it groups packages into use cases instead of asking you to choose individual libraries. The opencl use case installs ROCr-based OpenCL and the ROCm language runtime for “applications requiring OpenCL on Vega or later products”. The openclsdk use case adds development and SDK files.

sudo amdgpu-install --usecase=opencl

Check hardware support before you commit a node type: ROCm’s OpenCL runtime officially supports a small range of GPU models, and other cards may get only unofficial or partial support.

Intel

Intel’s Compute Runtime (NEO) provides OpenCL and Level Zero for Intel graphics architectures (HD Graphics and Xe). It covers Gen12 integrated graphics and newer, including all discrete Intel GPUs. On Ubuntu 22.04 the distribution package is intel-opencl-icd. Runtimes for Ubuntu 24.04 and 26.04 are published as .deb sets: you download them, check the sha256 sums and install with sudo dpkg -i *.deb. Legacy platforms are pointed at the 24.35 release procedure instead.

Mesa’s Rusticl

Mesa also ships an OpenCL implementation, Rusticl, which runs on Gallium drivers. By default it advertises no devices: you have to set RUSTICL_ENABLE to switch it on, because enabling it by default “can impact system stability”. This matters on mixed fleets, because a node with Rusticl installed but not enabled shows no Rusticl devices.

How Do You Verify That OpenCL Sees Your GPU Devices After Installation?

clinfo prints every OpenCL platform on the system and the devices each one exposes. That makes it the right verification tool, because it loads the same OpenCL dispatcher library your workloads link against. The project describes it as the way to “verify that your OpenCL environment is set up correctly”.

Three readings tell you the state of a node:

  • ls /etc/OpenCL/vendors shows which implementations are registered.
  • clinfo -l lists the platforms and the devices they expose. The number of GPU devices should equal the number of GPUs in the chassis.
  • If clinfo fails to build from source on a development node, chances are high that no other OpenCL application will build either.

Count what you see, not just whether you see something. If an eight-GPU node reports one CPU platform and no GPU platform, the loader is working and the vendor runtime is not. For PoCL and other CPU runtimes, see our guide to PoCL as a portable OpenCL runtime.

Why Does OpenCL Code Compile but Report Zero Devices at Runtime?

OpenCL code compiles without any device because compiling and linking only need the headers and the loader library, while finding a device happens at runtime through whatever .icd files the loader can open. A successful build shows the loader is present, not that a runtime is.

The two errors you will see correspond to two different layers. clGetPlatformIDs returns CL_PLATFORM_NOT_FOUND_KHR when the cl_khr_icd extension is supported but zero platforms are available, meaning the loader loaded and found no usable runtime. clGetDeviceIDs returns CL_DEVICE_NOT_FOUND when a platform exists but no device matches the requested device_type, for example asking for a GPU on a platform that only exposes a CPU.

Zero-Device Diagnostic Checklist

Symptom Likely cause Check or fix
CL_PLATFORM_NOT_FOUND_KHR No .icd file, or it names a library that fails to load ls /etc/OpenCL/vendors; register the ICD manually if needed
Runtime installed, still no platform Vendor library lacks the required ICD entry points and was ignored The loader drops libraries missing clIcdGetPlatformIDsKHR and two other functions
NVIDIA platform present, no devices /dev/nvidia* missing or wrong permissions NVIDIA’s guide names this cause when CUDA’s deviceQuery sees no device
Intel GPU not visible to a service user No access to /dev/dri/renderD* Grant the user permissions on the render nodes
Mesa platform with no devices Rusticl not enabled Set RUSTICL_ENABLE for the driver
Works on the host, fails in a conda environment The environment’s own loader cannot see system ICDs Install ocl-icd-system into the environment
CL_DEVICE_NOT_FOUND Platform exists, but not for the requested device type Query the GPU type on the right platform

NVIDIA’s guidance on /dev/nvidia* is written about CUDA’s deviceQuery. On an NVIDIA OpenCL failure, check the same device nodes first.

When the cause is not obvious, ask the loader what it is doing. With ocl-icd, OCL_ICD_DEBUG prints warnings, informational messages and a dump of the loaded ICDs, provided the library was built with debug support. Setting export OCL_ICD_DEBUG=7 before launching the application gives more output about what the loader is doing. OPENCL_VENDOR_PATH changes the default /etc/OpenCL/vendors path, and OCL_ICD_VENDORS takes priority when it is set and not empty. The ICD Loader also accepts OCL_ICD_FILENAMES, which loads the listed ICDs before any it discovers by default.

How Does Per-Node OpenCL Setup Fit into Provisioning a GPU Cluster?

On a cluster, the OpenCL check belongs in provisioning as a gate a node must pass before it joins, not as something you debug once jobs start failing.

The gate we would write into a node image or configuration playbook is short:

  1. The pinned driver or runtime version is installed (the same branch across the fleet).
  2. The expected .icd files are present in /etc/OpenCL/vendors.
  3. Device nodes (/dev/nvidia* or /dev/dri/renderD*) are accessible to the account the jobs run under.
  4. Run as that account, clinfo -l reports exactly the expected number of GPU devices.
  5. If workloads run in containers, the same check passes inside a container on that node.

The container step catches a failure the host check cannot. With the NVIDIA Container Toolkit, the compute driver capability is “required for CUDA and OpenCL applications”, and the NVIDIA OpenCL ICD file appears in the container when it is present on the host. NVIDIA_DRIVER_CAPABILITIES replaces the default capabilities (utility, compute) rather than adding to them, so a job spec that sets only graphics or video removes compute and, with it, OpenCL inside the container. A node can pass the host gate and still give its containers zero devices.

Getting this layer right is the end of the work that starts with GPU cluster interconnect planning. Once every node passes the gate, the open question becomes whether the workloads actually keep those devices busy, which is the subject of our GPU performance engineering work. For teams whose OpenCL code needs to run across vendors, our practical guide to portable OpenCL inference backends on Linux covers what changes after the install succeeds.

The judgement to carry into your own provisioning is narrow. Decide what “correct” looks like for each node type (which platform, how many devices, under which user, inside which container runtime), and make the node prove it before it receives work. A device count written down in advance turns a silent failure into a failed check at provisioning time.