How to install OpenCL for Nvidia GPU on Debian 11 (Bullseye)

For supported chips, it is as simple as installing the nvidia-opencl-icd package (from the non-free component). You can then list OpenCL capabilities by running clinfo from the clinfo package. This also works on headless machines.

If you don’t know if your chip is supported, try running nvidia-detect from the nvidia-detect package.

Donating computing power to Science: How to run containerized BOINC with OpenCL and VirtualBox

Containerized, hardware accelerated, and virtualized!

Don’t you want to do something more useful with your silicon and electricity than producing low entropy outputs of hash functions?

There is a way. From Wikipedia:

The Berkeley Open Infrastructure for Network Computing (BOINC, pronounced /bɔɪŋk/ – rhymes with “oink”) is an open-source middleware system for volunteer computing and grid computing.

From the official BOINC website:

BOINC lets you help cutting-edge science research using your computer. The BOINC app, running on your computer, downloads scientific computing jobs and runs them invisibly in the background. It’s easy and safe.

Needless to say, the security conscientious among us will raise one or even two eyebrows when they read that some maybe non-Open Source binary blobs are automatically downloaded from somewhere in the internet and then executed on your machine. But not to worry! One of the purposes of containers was exactly to solve that; to isolate software. Again from Wikipedia:

OS-level virtualization is an operating system paradigm in which the kernel allows the existence of multiple isolated user space instances. Such instances, called containers […] may look like real computers from the point of view of programs running in them. A computer program running on an ordinary operating system can see all resources (connected devices, files and folders, network shares, CPU power, quantifiable hardware capabilities) of that computer. However, programs running inside of a container can only see the container’s contents and devices assigned to the container.

So I set out to develop a Docker Container image which allows running BOINC with full hardware power (GPU computing via OpenCL, virtualization via VirtualBox), but in complete isolation of the host system.

For AMD GPUs, this was a bit more straightforward than for NVIDIA GPUs.

For AMD GPUs, I just published this small but sweet Dockerfile project on Github which sets up a minimal image with software only from the official Debian repository. See https://github.com/michaelfranzl/container-boinc

For NVIDIA, the host system needs additional software from non-Debian repositories to be able to ‘forward’ the GPU into containers. This will be the topic of a future blog post.

Meanwhile, happy number crunching!

How to install FOSS OpenCL for AMD GPU on Debian 11 (Bullseye)

It is very easy to set up free-and-open-source OpenCL computing support if you have an AMD GPU and Debian 11:

apt install ocl-icd-libopencl1 mesa-opencl-icd

Then use clinfo (from the package clinfo) to display information about your platform.

You can now use /dev/dri and the files in /etc/OpenCL to run OpenCL applications.

(Many thanks to the author of this blog post.)