You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from cuda import cudart as cu
err, _, _ = cu.cudaGLGetDevices(1, cu.cudaGLDeviceList.cudaGLDeviceListAll)
print(err)
# cudaError_t.cudaErrorOperatingSystem
Hi @leviome, I'm assuming that the code shared is just a snippet of the API call after you've already created a GL context. When I run the snippet as is, I get cudaError_t.cudaErrorInvalidGraphicsContext which seems expected since a GL context needs to be created before this call IIUC.
However, here's what I ran to attempt a repro:
# need to install pygame, pyopengl, cuda-python (best through conda-forge)
import pygame as pg
from OpenGL import EGL
from cuda import cudart
if __name__ == "__main__":
pg.init()
display_size = (640, 480)
pg.display.set_mode(display_size, pg.OPENGL | pg.DOUBLEBUF | pg.RESIZABLE)
# check opengl context is created
assert EGL.eglGetCurrentContext() is not None
print(cudart.cudaGLGetDevices(1, cudart.cudaGLDeviceList.cudaGLDeviceListAll))
but this returns cudaError_t.cudaSuccess, implying that the bindings are working as expected. Therefore it's likely there's something happening in one of your prior calls or how your system is configured.
If you think there're prior calls that complicate the binding of cudaGLGetDevices API, a full snippet would be helpful. Otherwise the bindings look ok, so this issue can be closed.
Activity
leofang commentedon Nov 21, 2024
We are investigating internally.
vzhurba01 commentedon Feb 27, 2025
Hi @leviome, I'm assuming that the code shared is just a snippet of the API call after you've already created a GL context. When I run the snippet as is, I get
cudaError_t.cudaErrorInvalidGraphicsContextwhich seems expected since a GL context needs to be created before this call IIUC.However, here's what I ran to attempt a repro:
but this returns
cudaError_t.cudaSuccess, implying that the bindings are working as expected. Therefore it's likely there's something happening in one of your prior calls or how your system is configured.If you think there're prior calls that complicate the binding of cudaGLGetDevices API, a full snippet would be helpful. Otherwise the bindings look ok, so this issue can be closed.