18

Numpy can be "linked/compiled" against different BLAS implementations (MKL, ACML, ATLAS, GotoBlas, etc). That's not always straightforward to configure but it is possible.

Is it also possible to "link/compile" numpy against NVIDIA's CUBLAS implementation?
I couldn't find any resources in the web and before I spend too much time trying it I wanted to make sure that it possible at all.

Ümit
  • 17,379
  • 7
  • 55
  • 74

2 Answers2

19

In a word: no, you can't do that.

There is a rather good scikit which provides access to CUBLAS from scipy called scikits.cuda which is built on top of PyCUDA. PyCUDA provides a numpy.ndarray like class which seamlessly allows manipulation of numpy arrays in GPU memory with CUDA. So you can use CUBLAS and CUDA with numpy, but you can't just link against CUBLAS and expect it to work.

There is also a commercial library that provides numpy and cublas like functionality and which has a Python interface or bindings, but I will leave it to one of their shills to fill you in on that.

talonmies
  • 70,661
  • 34
  • 192
  • 269
  • 1
    Thanks for the info. I know about the various Python libraries that allows access to CUDA. However I though if I could just configure Numpy to use Cublas I wouldn't have to change anything in the existing code (currently it uses ``numpy.dot()`` and other Linealg functions with MKL or GotoBlas2) and I could do performance comparisons. Just out of curiosity: Do you know by chance what the technical reasons are why it's not possible to link numpy against CUBLAS ? – Ümit Jul 20 '12 at 10:01
  • 1
    It is because the API isn't the same, and there is a whole layer of memory management that a standard blas application knows nothing about. – talonmies Jul 20 '12 at 10:16
  • 1
    This might changhe the situation: http://devblogs.nvidia.com/parallelforall/drop-in-acceleration-gnu-octave/ although this applies to octave it should also work for Numpy – Ümit Sep 16 '14 at 21:05
  • Is https://cupy.chainer.org/ better than the things in your answer? – endolith Jan 16 '20 at 15:22
4

here is another possibility :

http://www.cs.toronto.edu/~tijmen/gnumpy.html

this is basically a gnumpy + cudamat environment which can be used to harness a GPU. also the same code can be run without the gpu using npmat. refer to the link above to download all these files.

sidquanto
  • 315
  • 3
  • 6