vispy icon indicating copy to clipboard operation
vispy copied to clipboard

Add CuPy support

Open djhoese opened this issue 4 years ago • 4 comments

CuPy (https://docs.cupy.dev/en/stable/index.html) is a numpy-compatible array library that uses CUDA for improved performance. What this means is that CuPy arrays live on and are computed on the GPU. It should be theoretically possible to share a CUDA buffer (or however CuPy stores the array data) with OpenGL and therefore VisPy.

This would allow for some really unique workflows where users could do very complex calculations in-GPU with CuPy and visualize them "instantly" without having to copy data back and forth between GPU and CPU memory.

djhoese avatar Feb 11 '21 19:02 djhoese

See #1986 for some more in-depth cuda talk.

djhoese avatar Mar 17 '21 01:03 djhoese

This would be amazing, I found myself toying with interactive tools ideas lately, and every time the bottleneck ended up being this. I'd love to be able to simply replace my numpy with cupy and get direct access to vispy's texture buffers!

brisvag avatar Sep 07 '21 09:09 brisvag

@brisvag What type of work are you doing? Your use case sounds like the opposite of what I had in mind here. My thought is that VisPy could visualize the results of CuPy work (read only). By saying "access to vispy's texture buffers" are you saying you want to read what vispy has produced and use it in CuPy?

djhoese avatar Sep 07 '21 11:09 djhoese

No, I think we mean the same thing, I just expressed myself poorly :) I'd like to be able to visualize quickly and in real time what happens to the data. This becomes unwieldy when working with big volumes, because every single time they are updated vispy had to make a copy of the data and transfer it to GPU memory. I tried to dive in the gloo and cupy code and understand where exactly the data gets passed to the buffer and how, but it quickly became clear that this is way over my level :)

brisvag avatar Sep 07 '21 12:09 brisvag