Preparing Ubuntu 18.04LTS as an OpenCL development platform:
With OpenCL, the installable client drivers (ICDs) are normally issued with the accelerator's device drivers, namely:
- The NVIDIA CUDA toolkit (and the device driver) for NVIDIA GPUs.
- AMD's RoCM for GCN-class AMD hardware.
- Intel's beignet and the newer Neo compute runtime.
The purpose of the installable client driver model is to allow multiple OpenCL platforms to coexist on the same platform. That way, multiple OpenCL accelerators, be they discrete GPUs paired with a combination of FPGAs and integrated GPUs can all coexist.
However, for linkage purposes, you'll require the ocl-icd package, which can be installed by:
sudo apt install ocl-icd-* opencl-headers
Why ocl-icd? Simple: Whereas other ICDs may permit you to link against them directly, it is discouraged so as to limit the risk of unexpected runtime behavior. Assume ocl-icd to be the gold link target if your goal is to be platform-neutral as possible.
Practical example: Deploying Pyrit, a WPA precomputed cracker that has accelerated backends in OpenCL (and CUDA):
Fetch the source:
git clone https://github.com/JPaulMora/Pyrit.git
Install build dependencies:
sudo pip install psycopg2 scapy sudo apt-get install libpcap-dev
Configure the build:
cd Pyrit python setup.py clean python setup.py build sudo python setup.py install
cd Pyrit/modules/cpyrit_opencl python setup.py build sudo python setup.py install
Should list OpenCL cores.
Optionally, for CUDA:
cd modules/cpyrit-cuda/ python setup.py build sudo python setup.py install
Configuring which accelerator to use:
To enable GPU computing, you must edit your config file located at
~/.pyrit/config and set either CUDA or OpenCl to 'true' like so:
use_CUDA = false use_OpenCL = true
limit_ncpus is set to a number below zero (say, -1), Pyrit will disable all CPU cores, piping the work to the GPU, which is usually more (power and performance) efficient.
An example of expected output is shown below.