pycuda icon indicating copy to clipboard operation
pycuda copied to clipboard

DLPack support in PyCUDA?

Open OhadRubin opened this issue 6 years ago • 5 comments

DLPack is a community effort to define a common tensor data structure that could be shared by different frameworks. Currently, Pytorch and MXNet have adopted this interface, and Tensorflow is the progress of adopting it. Using DLPack can benefit many projects in the ecosystem. So it will be really great if PyCUDA can also adopt this interface to help new ideas derived from the mainstream tensor-based frameworks. Related: https://github.com/tensorflow/tensorflow/issues/24453

OhadRubin avatar Dec 16 '19 20:12 OhadRubin

FYI, CuPy already supports it for a while: https://docs-cupy.chainer.org/en/latest/reference/interoperability.html#dlpack

leofang avatar Jul 10 '20 05:07 leofang

I'm generally supportive, and I'd be happy to consider a patch/PR. Writing one shouldn't be super hard.

inducer avatar Jul 10 '20 16:07 inducer

I would like to help implement dlpack for pycuda. Can you help point me to what function I should write and it's reference from other lib @inducer ?

lamhoangtung avatar Nov 07 '21 17:11 lamhoangtung

Is there a canonical Python wrapper for dlpack? If so, you'd just need to import that and fill it with data from a GPUArray (or fill a GPUArray with data from one).

inducer avatar Nov 07 '21 18:11 inducer

See https://data-apis.org/array-api/latest/design_topics/data_interchange.html?highlight=dlpack.

leofang avatar Nov 07 '21 19:11 leofang