Skip to content

Conversation

@pijyoi
Copy link
Contributor

@pijyoi pijyoi commented Oct 1, 2025

This PR implements CUDA OpenGL interops for RawImageGLWidget. It is gated behind enableExperimental.

It also fixes the issue highlighted in #3373 that cupy was not working with RawImageGLWidget at all.

@pijyoi pijyoi force-pushed the cuda-opengl branch 2 times, most recently from 2947bf2 to 54426df Compare October 4, 2025 04:55
@pijyoi
Copy link
Contributor Author

pijyoi commented Oct 4, 2025

cuda-bindings (https://pypi.org/project/cuda-bindings/) needs to be installed. If it is not, the code will silently transfer the gpu data back to cpu.
Be sure to install the version of cuda-bindings with the same major version as your CUDA toolkit version.

NOTE: cuda-bindings 12.9.3 and 13.0.2 do not work for this PR. (reported in NVIDIA/cuda-python#1122)

import cupy as xp
import pyqtgraph as pg

pg.setConfigOption('imageAxisOrder', 'row-major')
pg.setConfigOption('useCupy', True)

X = xp.linspace(-1, 1, 1024, dtype=xp.float32)
Y = X[:, None]
Z = xp.sin(20 * 2 * xp.pi * (Y**2 + X**2))

pg.mkQApp()
win = pg.RawImageGLWidget()
win.setImage(Z, levels=[-1, 1])
win.show()
pg.exec()
print(win.gfx_resource)    # None if it didn't go through GPU
win.cleanup()

@pijyoi pijyoi marked this pull request as ready for review October 4, 2025 14:14
@j9ac9k
Copy link
Member

j9ac9k commented Nov 15, 2025

My apologies @pijyoi for keeping this PR in the queue for so long. Getting this functionality baked into the library has been on the wish list for quite some time. Thank you for making it happen!

@j9ac9k j9ac9k merged commit f5184ac into pyqtgraph:master Nov 15, 2025
36 checks passed
@pijyoi pijyoi deleted the cuda-opengl branch November 15, 2025 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants