Skip to content

MVP python BLAS example #8

Answered by szkarpinski
akochepasov asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @akochepasov ! Thank you for your interest in nvmath-python.

The problem that I see in your code is that cuBLAS expect the matrices to be on the GPU, and passing host-side pointers might result in undefined behaviour. I guess the error you are seeing might be caused by that. Can you please try to convert your A and C numpy arrays to CuPy arrays and check if this fixes the error?

CuPy has .random and .zeros, so you just need to change np to cp when creating the arrays:

import cupy as cp

A = cp.random.random((m, n))
C = cp.zeros((n, n))

And to get the pointers to CuPy, you can use .data.ptr instead of ctypes.data:

nvmath.bindings.cublas.dsyrk(hndl, uplo_, trans_, n, k, 
    a.ctypes…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@akochepasov
Comment options

@szalpal
Comment options

@akochepasov
Comment options

@szkarpinski
Comment options

Answer selected by leofang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants