This page covers the installation of the OpenCL SDK, consisting of the C and C++ headers, as well as the ICD loader.
ICD stands for "Installable Client Driver" in which the ICD loader just loads given drivers that are installed on the system, given that an ICD file is present that declares the driver exists. This is how the Vulkan ICD loader from the Vulkan SDK works.
OpenCL drivers often come from video drivers, like Mesa and NVIDIA.
First, create a list of files to be downloaded:
cat > opencl-sdk-list-2025.07.22 << "EOF"
OpenCL-Headers/archive/v2025.07.22/OpenCL-Headers-2025.07.22.tar.gz
OpenCL-CLHPP/archive/v2025.07.22/OpenCL-CLHPP-2025.07.22.tar.gz
OpenCL-ICD-Loader/archive/v2025.07.22/OpenCL-ICD-Loader-2025.07.22.tar.gz
EOF
To download the needed files using Wget-1.25.0, use the following commands:
mkdir opencl-sdk-2025.07.22 &&
cd opencl-sdk-2025.07.22 &&
grep -v '^#' ../opencl-sdk-list-2025.07.22 | wget -i- -c \
-B https://github.com/KhronosGroup/
When installing multiple packages in a script, the installation needs to be done as the root user. There are three general options that can be used to do this:
Run the entire script as the root user (not recommended).
Use the sudo command from the sudo package.
Use su -c "command arguments" (quotes required) which will ask for the root password for every iteration of the loop.
One way to handle this situation is to create a short bash function that automatically selects the appropriate method. Once the command is set in the environment, it does not need to be set again.
as_root()
{
if [ $EUID = 0 ]; then $*
elif [ -x /usr/bin/sudo ]; then sudo $*
else su -c \\"$*\\"
fi
}
export -f as_root
First, start a subshell that will exit on error:
bash -e
Install all of the packages by running the following commands:
for package in OpenCL-{Headers,CLHPP,ICD-Loader}
do
longpackage=$package-2025.07.22.tar.?z*
packagedir=${longpackage%.tar.?z*}
tar -xf $longpackage
pushd $packagedir
mkdir build
cd build
cmake -D CMAKE_INSTALL_PREFIX=/usr \
-D CMAKE_BUILD_TYPE=Release \
-D BUILD_TESTING=OFF \
-D BUILD_EXAMPLES=OFF \
-G Ninja ..
ninja
as_root ninja install
popd
rm -rf $packagedir
done
Finally, exit the shell that was started earlier:
exit