Discussion:
[PyCUDA] cublas, DgemmBatched
Keith Brown
2015-11-18 01:17:28 UTC
Permalink
Hi,

I have been using scikit-cudablas
(https://github.com/lebedov/scikit-cuda). It rocks!

Does anyone have a 2d matrix multiplication example with DgemmBatched?

Similar to,
a=np.random.randint(0,3,(16,2)); b=np.random.randint(0,4,(2,16))
np.dot(a,b)
I have been using,
https://github.com/lebedov/scikit-cuda/blob/7e7300474286019c917a6c8a4bca59405c64fbce/tests/test_cublas.py#L531
but it has too many dimensions and I keep getting confused by too many
dimensions for DgemmBatched
Lev Givon
2015-11-18 22:22:36 UTC
Permalink
Post by Keith Brown
Hi,
I have been using scikit-cudablas
(https://github.com/lebedov/scikit-cuda). It rocks!
Does anyone have a 2d matrix multiplication example with DgemmBatched?
Similar to,
a=np.random.randint(0,3,(16,2)); b=np.random.randint(0,4,(2,16))
np.dot(a,b)
Not sure I follow what you want to do - batched GEMM is intended for concurrent
matrix multiplication of collections of matrices (effectively 3rd-order
tensors). Do you want to obtain the products of the individual submatrices within
the two matrices above, i.e., something like [np.dot(a[0:2,:], b[:,0:2]), np.dot(a[2:4,:],
b[:,2:4]), ...]?
Post by Keith Brown
I have been using,
https://github.com/lebedov/scikit-cuda/blob/7e7300474286019c917a6c8a4bca59405c64fbce/tests/test_cublas.py#L531
but it has too many dimensions and I keep getting confused by too many
dimensions for DgemmBatched
--
Lev Givon
Bionet Group | Neurokernel Project
http://lebedov.github.io/
http://neurokernel.github.io/
Keith Brown
2015-11-19 03:12:13 UTC
Permalink
I am trying to calculate the dot product.

something like this,

A=np.array(([1,2,3],[4,5,6])).astype(np.float64)
print np.dot(A,A.T)

Instead, I would like to use GEMM (not batched I suppose).

My A can be large. Something like (800000,3). So, it would seem GPU
could help me a lot here.
Post by Lev Givon
Post by Keith Brown
Hi,
I have been using scikit-cudablas
(https://github.com/lebedov/scikit-cuda). It rocks!
Does anyone have a 2d matrix multiplication example with DgemmBatched?
Similar to,
a=np.random.randint(0,3,(16,2)); b=np.random.randint(0,4,(2,16))
np.dot(a,b)
Not sure I follow what you want to do - batched GEMM is intended for concurrent
matrix multiplication of collections of matrices (effectively 3rd-order
tensors). Do you want to obtain the products of the individual submatrices within
the two matrices above, i.e., something like [np.dot(a[0:2,:], b[:,0:2]), np.dot(a[2:4,:],
b[:,2:4]), ...]?
Post by Keith Brown
I have been using,
https://github.com/lebedov/scikit-cuda/blob/7e7300474286019c917a6c8a4bca59405c64fbce/tests/test_cublas.py#L531
but it has too many dimensions and I keep getting confused by too many
dimensions for DgemmBatched
--
Lev Givon
Bionet Group | Neurokernel Project
http://lebedov.github.io/
http://neurokernel.github.io/
Lev Givon
2015-11-19 04:35:16 UTC
Permalink
Post by Keith Brown
I am trying to calculate the dot product.
something like this,
A=np.array(([1,2,3],[4,5,6])).astype(np.float64)
print np.dot(A,A.T)
Instead, I would like to use GEMM (not batched I suppose).
My A can be large. Something like (800000,3). So, it would seem GPU
could help me a lot here.
The skcuda.linalg.dot() function in scikit-cuda uses the CUBLAS GEMM functions when both
arguments have more than one dimension and sufficient GPU memory is available.
--
Lev Givon
Bionet Group | Neurokernel Project
http://lebedov.github.io/
http://neurokernel.github.io/
Loading...