Installing pyclblast on OpenSuse 15.2
First things first, you should really take it serious all the information that nvidia says regarding the Linux distro and version that you are planning to use as your base GPU development platform. Failing to comply with the versions leads to chaos, terror, suffering and pain, believe me for I have tried many combinations!
So, since I am a OpenSuse user and my system is equipped with an RTX2060 the choice is CUDA 11.1, which is compatible with Leap 15.2.
Beware! You should NOT install the nvidia repository for drivers! Instead, you should install the cuda repository and install the nvidia driver that is compatible with the CUDA SDK that you plan to use. (I know, some links here and there will be helpful and I will insert them later…)
Once you have the basic infrastructure in place let’s talk about the higher level use.
Programming GPUs is not exactly simple, however it may be easier if what you want to do is “just” linear algebra thanks to a library called BLAS. The CUDA SDK comes with an implementation called cuBLAS that provides all the necessary functions to perform your computations.
But what if you would like something a little more open-source? Well, in that case you would be happy to know CLBlast a hardware independent BLAS implementation that is based on OpenCL (which CUDA SDK supports as well). The good news is that your program would also run on hardware other than nvidia devices.
But what if you don’t want to mess with all the low level programming details? For that case CLBlast already comes with a Python wrapper for the library.
So, without further ado, let’s jump into the guide to have this library in place:
Step 1, clone the repository and build it, this is basic cmake stuff
git clone https://github.com/CNugteren/CLBlast.git
cd CLBlast/
mkdir build
cd build
cmake ..
make
You will need libOpenCL installed (your distribution repository should have it), however, for OpenSuse Leap 15.2 this DOES NOT provide libOpenCL.so, instead it provides only libOpenCL.so.1, I had to create a symbolic link
You will also need opencl-headers so that everything compiles correctly
Step 2, pyclblast needs a lot of Python libraries so I recommend creating a virtual environment to protect your system from library conflicts
python3 -m venv opencl
source opencl/bin/activate
pip install numpy
pip install pyopencl
pip install Cython
pip install pybind11
pip install pyopencl
pip install pyclblast
Step 3, play with it!
python ../src/pyclblast/samples/sgemm.py
As I mentioned before, CLBlast provides pyclblast so the samples are at the cloned repository