Armadillo (+BLAS) using GPU
Asked Answered
B

3

9

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.

Barrio answered 1/8, 2013 at 1:26 Comment(0)
A
0

No, it is not.

You cannot take code for the cpu and assume it runs on the gpu as both have completely different memory models, hardware, programming styles etc pp.

Absenteeism answered 1/8, 2013 at 1:29 Comment(2)
as mentioned in the other answer and the FAQ, you can use NVBLAS or ACML: arma.sourceforge.net/faq.htmlUndervest
Keep in mind that I wrote the answer in August of 2013; there have been dozens of Armadillo (and CUDA !!) releases since.Absenteeism
F
22

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

Fedak answered 28/3, 2014 at 11:12 Comment(0)
A
0

No, it is not.

You cannot take code for the cpu and assume it runs on the gpu as both have completely different memory models, hardware, programming styles etc pp.

Absenteeism answered 1/8, 2013 at 1:29 Comment(2)
as mentioned in the other answer and the FAQ, you can use NVBLAS or ACML: arma.sourceforge.net/faq.htmlUndervest
Keep in mind that I wrote the answer in August of 2013; there have been dozens of Armadillo (and CUDA !!) releases since.Absenteeism
C
0

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.

Casiecasilda answered 26/1, 2022 at 8:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.