A tutorial to show how to install OpenCL support for NVIDIA, Intel and AMD GPUs under Ubuntu / Linux Mint; a specific paragraph addresses OpenCL support for microprocessors and virtual machines guests.
What is OpenCL? "OpenCL (Open Computing Language) is a framework for writing programs that execute across heterogeneous platforms consisting of central processing units (CPUs), graphics processing units (GPUs), digital signal processors (DSPs), field-programmable gate arrays (FPGAs) and other processors or hardware accelerators".
So, OpenCL can use the processing power of all your hardware, including GPUs. Apps need to be designed for OpenCL and eventually set-up for its use. An example: when you select OpenCL in LibreOffice preferences, Calc will use it and will perform large calculations faster.
Wikipedia has a list of applications using OpenCL: https://en.wikipedia.org/wiki/List_of_O ... plications
Disclaimer: the author does not assume any responsibility about any damages on your computer occurring when following this tutorial. Users are strongly encouraged to backup their system before applying this tutorial in order to recover former system functioning if anything wrong occurred.
1) Identifying your GPU(s):
If you don't know what GPU is inside your computer you can:
- Refer to the manufacturer specification.
- Use lspci, example below
Code: Select all
$ lspci
Here the computer is equipped with a NVIDIA GF116M [GeForce GT 560M]00:00.0 Host bridge: Intel Corporation 2nd Generation Core Processor Family DRAM Controller (rev 09)
00:01.0 PCI bridge: Intel Corporation Xeon E3-1200/2nd Generation Core Processor Family PCI Express Root Port (rev 09)
00:16.0 Communication controller: Intel Corporation 6 Series/C200 Series Chipset Family MEI Controller #1 (rev 04)
00:1a.0 USB controller: Intel Corporation 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #2 (rev 05)
00:1b.0 Audio device: Intel Corporation 6 Series/C200 Series Chipset Family High Definition Audio Controller (rev 05)
00:1c.0 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 1 (rev b5)
00:1c.1 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 2 (rev b5)
00:1c.3 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 4 (rev b5)
00:1c.5 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 6 (rev b5)
00:1d.0 USB controller: Intel Corporation 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #1 (rev 05)
00:1f.0 ISA bridge: Intel Corporation HM65 Express Chipset LPC Controller (rev 05)
00:1f.2 SATA controller: Intel Corporation 6 Series/C200 Series Chipset Family 6 port Mobile SATA AHCI Controller (rev 05)
00:1f.3 SMBus: Intel Corporation 6 Series/C200 Series Chipset Family SMBus Controller (rev 05)
01:00.0 VGA compatible controller: NVIDIA Corporation GF116M [GeForce GT 560M] (rev a1)
01:00.1 Audio device: NVIDIA Corporation GF116 High Definition Audio Controller (rev a1)
03:00.0 Network controller: Qualcomm Atheros AR9285 Wireless Network Adapter (PCI-Express) (rev 01)
04:00.0 USB controller: Fresco Logic FL1000G USB 3.0 Host Controller (rev 04)
05:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 06)
Or, just for GPU output:
Code: Select all
lspci -nnk | grep -EA3 "3D|VGA"
- Use inxi; you should first update it:01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GF116M [GeForce GT 560M] [10de:1251] (rev a1)
Subsystem: ASUSTeK Computer Inc. GF116M [GeForce GT 560M] [1043:204a]
Kernel driver in use: nvidia
Kernel modules: nvidiafb, nouveau, nvidia_drm, nvidia
Code: Select all
sudo inxi -U
Code: Select all
$ inxi -G
Code: Select all
Graphics:
Device-1: NVIDIA GF116M [GeForce GT 560M] driver: nvidia v: 390.144
Device-2: IMC Networks Integrated Webcam type: USB driver: uvcvideo
Display: x11 server: X.Org 1.20.11 driver: loaded: nvidia
unloaded: fbdev,modesetting,nouveau,vesa resolution: 1920x1080~60Hz
OpenGL: renderer: GeForce GTX 560M/PCIe/SSE2 v: 4.6.0 NVIDIA 390.144
2) NVIDIA GPUs:
NVIDIA GPUs video drivers and OpenCL are normally installed during Linux Mint installation, if you accepted to install third-party software by selecting "Install third-party software for graphics and Wi-Fi hardware, Flash, mp3 and other media" (this, in accordance with Linux Mint Installation Guide https://linuxmint.com/documentation.php; on most recent versions of Linux Mint, they might be installed anyway).
They can be also installed after installation, using Control center / Drivers manager; Drivers manager will offer to install NVIDIA driver or free Xorg one, and will indicate the latest available NVIDIA driver as the recommended one.
It may arrive that recent NVIDIA drivers, when released, do not appear in drivers repository before weeks.
To use recent drivers as soon as released, the simplest way is to use a ppa: https://launchpad.net/~graphics-drivers ... ubuntu/ppa
To install this ppa:
Code: Select all
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
Code: Select all
sudo clinfo
Code: Select all
number of platforms 1
Platform Name NVIDIA CUDA
Platform Vendor NVIDIA Corporation
Platform Version OpenCL 1.2 CUDA 9.1.84
Platform Profile FULL_PROFILE
Code: Select all
ICD loader properties
ICD loader Name OpenCL ICD Loader
ICD loader Vendor OCL Icd free software
ICD loader Version 2.2.11
ICD loader Profile OpenCL 2.1
3) Intel GPUs:
Intel OpenSource graphics drivers are part of the kernel and are installed during Linux Mint installation.
There are two possible OpenCL installations. (See https://linuxreviews.org/OpenCL)
Beignet:
Beignet is a Intel-iGPU specific OpenCL implementation developed by Intel China in 2013. It was maintained until around 2017 before it was abandoned in favor of Intel's Neo OpenCL library. Beignet can be used to do OpenCL 1.2 on Ivy Bridge processors a higher and it will provide limited OpenCL 2.0 support on Skylake and newer processors.
In order to enable OpenCL with Beignet, you have to install two packages (and their dependencies) and clinfo to check:
Code: Select all
sudo apt-get install beignet-opencl-icd ocl-icd-libopencl1 clinfo
Source for this procedure: http://hansekbrand.se/code/OpenCL.html
Neo:
NEO is a OpenCL implementation from Intel, for Intel graphics only, with OpenCL 3.0 support on all Intel chips going back to Broadwell since version 20.40.18075. Earlier versions are limited to OpenCL 1.2, 2.1 or 3.0 depending on what CPU/iGPU you have chip. Intel has begun calling it "Intel(R) Graphics Compute Runtime for oneAPI Level Zero and OpenCL(TM) Driver". The NEO GitHub page states that: "NEO is the shorthand name for Compute Runtime contained within this repository. It is also a development mindset that we adopted when we first started the implementation effort for OpenCL."
Intel is only releasing Ubuntu packages for Neo. See https://github.com/intel/compute-runtime/releases for a table of Neo OpenCL support versus micro architecture and follow the installation procedure.
Then install clinfo to check all is OK:
Code: Select all
sudo apt-get install clinfo
4) AMD GPUs:
AMD OpenSource graphics drivers are part of the kernel and installed during Mint installation.
AMD provides proprietary Linux drivers and OpenCL support for a reduced set of references only. These AMD proprietary drivers are not available from Ubuntu / Linux Mint repositories.
a) GPU with AMD proprietary drivers for Linux:
At the time of this writing (December 2021), this page gives the links to download AMD Radeon Software for Linux and a compatibility table: https://www.amd.com/en/support/kb/relea ... ux-21-40-1.
(More generally, users should look for the most recent version at AMD support page https://www.amd.com/en/support)
If your AMD GPU is in the compatibility list, the preferred solution to have both graphics drivers and OpenCL support is to download and install AMD Radeon Software for Linux (choose Ubuntu 20.04 version for Linux Mint 20.x and Ubuntu 18.04 version for Linux Mint 19.x).
Detailed installation instructions are here, to be read carefully: https://amdgpu-install.readthedocs.io/en/21.40/
Note that some users want to use OpenSource graphics drivers and OpenCL support from AMD; they download AMD software, extract OpenCL files and install them. This installation method is out of the scope of this tutorial.
AMD also offers AMD ROCm technology for a limited number of GPUs, and for Ubuntu 18.04.5 / kernel 5.4.0-71-generic or Ubuntu 20.04.3HWE / kernel 5.8.0-48-generic. Installation procedures and documentation here: https://github.com/RadeonOpenCompute/ROCm.
b) GPU without AMD proprietary support for Linux:
If your GPU is not mentioned in the compatibility list, you will be let with the OpenSource graphics driver, and with an OpenSource OpenCL support.
WARNING: the following procedure is experimental
This applies to the GPUs taken into account by libclc-12 or by libclc-amdgcn.
libclc is an open implementation of the OpenCL C programming language, as specified by the OpenCL 1.1 Specification. This package (libclc-12) contains support for the amdgcn (AMD GPU), PTX and r600 platforms.
The list of files included in each of these libraries shows the GPU technologies taken into account.libclc is an open implementation of the OpenCL C programming language, as specified by the OpenCL 1.1 Specification. This package (libclc-amdgcn) contains support for the amdgcn (AMD GPU) platform. Supported GPU families: Southern Islands and newer.
For libclc-12:
Code: Select all
/usr/lib/clc/amdgcn--amdhsa.bc
/usr/lib/clc/aruba-r600--.bc
/usr/lib/clc/barts-r600--.bc
/usr/lib/clc/bonaire-amdgcn--.bc
/usr/lib/clc/caicos-r600--.bc
/usr/lib/clc/carrizo-amdgcn--.bc
/usr/lib/clc/cayman-r600--.bc
/usr/lib/clc/cedar-r600--.bc
/usr/lib/clc/cypress-r600--.bc
/usr/lib/clc/fiji-amdgcn--.bc
/usr/lib/clc/gfx900-amdgcn--.bc
/usr/lib/clc/gfx902-amdgcn--.bc
/usr/lib/clc/gfx904-amdgcn--.bc
/usr/lib/clc/gfx906-amdgcn--.bc
/usr/lib/clc/hainan-amdgcn--.bc
/usr/lib/clc/hawaii-amdgcn--.bc
/usr/lib/clc/hemlock-r600--.bc
/usr/lib/clc/iceland-amdgcn--.bc
/usr/lib/clc/juniper-r600--.bc
/usr/lib/clc/kabini-amdgcn--.bc
/usr/lib/clc/kaveri-amdgcn--.bc
/usr/lib/clc/mullins-amdgcn--.bc
/usr/lib/clc/nvptx--.bc
/usr/lib/clc/nvptx--nvidiacl.bc
/usr/lib/clc/nvptx64--.bc
/usr/lib/clc/nvptx64--nvidiacl.bc
/usr/lib/clc/oland-amdgcn--.bc
/usr/lib/clc/palm-r600--.bc
/usr/lib/clc/pitcairn-amdgcn--.bc
/usr/lib/clc/polaris10-amdgcn--.bc
/usr/lib/clc/polaris11-amdgcn--.bc
/usr/lib/clc/redwood-r600--.bc
/usr/lib/clc/stoney-amdgcn--.bc
/usr/lib/clc/sumo-r600--.bc
/usr/lib/clc/sumo2-r600--.bc
/usr/lib/clc/tahiti-amdgcn--.bc
/usr/lib/clc/tonga-amdgcn--.bc
/usr/lib/clc/turks-r600--.bc
/usr/lib/clc/verde-amdgcn--.bc
Code: Select all
/usr/lib/clc/amdgcn--amdhsa.bc
/usr/lib/clc/bonaire-amdgcn--.bc
/usr/lib/clc/bonaire-amdgcn--amdhsa.bc
/usr/lib/clc/bonaire-amdgcn-mesa-mesa3d.bc
/usr/lib/clc/carrizo-amdgcn--.bc
/usr/lib/clc/carrizo-amdgcn--amdhsa.bc
/usr/lib/clc/carrizo-amdgcn-mesa-mesa3d.bc
/usr/lib/clc/fiji-amdgcn--.bc
/usr/lib/clc/fiji-amdgcn--amdhsa.bc
/usr/lib/clc/fiji-amdgcn-mesa-mesa3d.bc
/usr/lib/clc/gfx900-amdgcn--.bc
/usr/lib/clc/gfx900-amdgcn--amdhsa.bc
/usr/lib/clc/gfx900-amdgcn-mesa-mesa3d.bc
/usr/lib/clc/gfx902-amdgcn--.bc
/usr/lib/clc/gfx902-amdgcn--amdhsa.bc
/usr/lib/clc/gfx902-amdgcn-mesa-mesa3d.bc
/usr/lib/clc/gfx904-amdgcn--.bc
/usr/lib/clc/gfx904-amdgcn--amdhsa.bc
/usr/lib/clc/gfx904-amdgcn-mesa-mesa3d.bc
/usr/lib/clc/gfx906-amdgcn--.bc
/usr/lib/clc/gfx906-amdgcn--amdhsa.bc
/usr/lib/clc/gfx906-amdgcn-mesa-mesa3d.bc
/usr/lib/clc/hainan-amdgcn--.bc
/usr/lib/clc/hainan-amdgcn-mesa-mesa3d.bc
/usr/lib/clc/hawaii-amdgcn--.bc
/usr/lib/clc/hawaii-amdgcn--amdhsa.bc
/usr/lib/clc/hawaii-amdgcn-mesa-mesa3d.bc
/usr/lib/clc/iceland-amdgcn--.bc
/usr/lib/clc/iceland-amdgcn--amdhsa.bc
/usr/lib/clc/iceland-amdgcn-mesa-mesa3d.bc
/usr/lib/clc/kabini-amdgcn--.bc
/usr/lib/clc/kabini-amdgcn--amdhsa.bc
/usr/lib/clc/kabini-amdgcn-mesa-mesa3d.bc
/usr/lib/clc/kaveri-amdgcn--.bc
/usr/lib/clc/kaveri-amdgcn--amdhsa.bc
/usr/lib/clc/kaveri-amdgcn-mesa-mesa3d.bc
/usr/lib/clc/mullins-amdgcn--.bc
/usr/lib/clc/mullins-amdgcn--amdhsa.bc
/usr/lib/clc/mullins-amdgcn-mesa-mesa3d.bc
/usr/lib/clc/oland-amdgcn--.bc
/usr/lib/clc/oland-amdgcn-mesa-mesa3d.bc
/usr/lib/clc/pitcairn-amdgcn--.bc
/usr/lib/clc/pitcairn-amdgcn-mesa-mesa3d.bc
/usr/lib/clc/polaris10-amdgcn--.bc
/usr/lib/clc/polaris10-amdgcn--amdhsa.bc
/usr/lib/clc/polaris10-amdgcn-mesa-mesa3d.bc
/usr/lib/clc/polaris11-amdgcn--.bc
/usr/lib/clc/polaris11-amdgcn--amdhsa.bc
/usr/lib/clc/polaris11-amdgcn-mesa-mesa3d.bc
/usr/lib/clc/stoney-amdgcn--.bc
/usr/lib/clc/stoney-amdgcn--amdhsa.bc
/usr/lib/clc/stoney-amdgcn-mesa-mesa3d.bc
/usr/lib/clc/tahiti-amdgcn--.bc
/usr/lib/clc/tahiti-amdgcn-mesa-mesa3d.bc
/usr/lib/clc/tonga-amdgcn--.bc
/usr/lib/clc/tonga-amdgcn--amdhsa.bc
/usr/lib/clc/tonga-amdgcn-mesa-mesa3d.bc
/usr/lib/clc/verde-amdgcn--.bc
/usr/lib/clc/verde-amdgcn-mesa-mesa3d.bc
As an example, if you have an AMD Radeon 530, this board is from 2017; Southern Islands has been issued in 2012; so this board is supported by libclc-amdgcn, said compatible with Southern Islands and newer.
There is however a trick; 1st step is to install OpenCL without libclc-12 or libclc-amdgcn.
Code: Select all
sudo apt-get install ocl-icd-libopencl1 mesa-opencl-icd ocl-icd-opencl-dev clinfo
Code: Select all
fatal error: cannot open file '/usr/local//usr/lib/clc/iceland-amdgcn-mesa-mesa3d.bc': No such file or directory
Code: Select all
sudo apt-get install libclc-amdgcn
Code: Select all
sudo apt-get install libclc-12
This installation procedure derives from: http://hansekbrand.se/code/OpenCLAgain.html with my own complements.
NB: Christmas gifts list
It would be nice if Linux Mint would install automatically OpenCL support for Intel and AMD GPUs (with proprietary or OpenSource support for AMD depending on the GPU model).
5) OpenCL support for microprocessors and virtual machines guests:
This part concerns system without a performing GPU, or virtual machines guests with no GPU pass through (with VM software such as VMware Workstation, VMware Workstation Player; or with Oracle Virtual Box...).
[In these VMs, GPU is simulated through software and, as a consequence, no OpenCL support can be installed for the GPU. However, OPenCL support can be installed for the microprocessor.]
a) Linux Mint / Ubuntu systems or VM guests:
OpenCL support for microprocessor can be simply done by installing libopcl2, and clinfo to check after installation:
Code: Select all
sudo apt-get install libpocl2 clinfo
(choose Linux version)
b) Windows VM guests:
Intel provides a CPU runtime for its microprocessors, while AMD has dropped support for its OpenCL SDK, leaving its microprocessors without any OpenCL support.
Intel CPU Runtime for OpenCL can be downloaded from this page (free registration needed): https://www.intel.com/content/www/us/en ... rview.html (choose Windows version)
On Windows 10 guests, an alternative solution is to install the "OpenCL and OpenGL Compatibility Pack" from the Windows Store.
(see this tutorial to know how to have DirectX in VMware guests: viewtopic.php?f=42&t=362350)This compatibility pack allows more of your favorite OpenCL™ and OpenGL® apps to run on a Windows 10 PC that doesn't have OpenCL and OpenGL hardware drivers installed by default. If a DirectX 12 driver is installed, supported apps will run with hardware acceleration for better performance. This package supports apps that use OpenCL version 1.2 and earlier and OpenGL version 3.3 and earlier.
Once installed, OpenCL presence can be tested with "GPU Caps Viewer", downloaded from https://www.geeks3d.com/dl/show/657
Feel free to comment or complete this tutorial.
Regards,
MN