'Armadillo (+BLAS) using GPU
Is it possible to run armadillos calculations using GPU? Is there any way to use the GPU blas libraries (for example cuBLAS) with armadillo? Just a note, I am totally new to GPU programming.
Solution 1:[1]
The current accepted answer is outdated. Comming with CUDA 6 (at the moment Release Candidate status), there is a true drop-in replacement called NVBLAS which takes care about GPU interaction and also works in combination with armadillo. You can use NVBLAS by linking your program agains libnvblas.so
However, not all BLAS methods may be available, so you have to specify a fallback-BLAS library (like openblas).
For more details, see https://developer.nvidia.com/cublasxt
Solution 2:[2]
I finally find a quick way on Ubuntu 20.04 with Cmake and CUDA.
Install CUDA
This seems very difficult according to the official guidance, but on Ubuntu 20 using apt works fine.
sudo apt install nvidia-cuda-toolkit
After this, do not forget to set the environmental variable NVBLAS_CONFIG_FILE according to documentation.
The default contents on the website will do except for changing the CPU BLAS library. For me, the libopenblas.a does not work and should be set as libopenblas.so.0.
Use Cmake to Compile Armadillo
The manual installation seems to be complex for me, so I just make some adjustments to the cmake install method.
cmake . -Dopenblas_LIBRARY=<PATH TO NVBLAS LIB>/libnvblas.so
Write Code Using Armadillo
The cmake project is just no different and no additional compiling flag is needed since they are all set when compiling the Armadillo library.
If anything went wrong, the log file (by default nvblas.log) will provide some information. It may be something like it can not open the CPU BLAS library.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | roemer |
| Solution 2 |
