cuGLGetDevices / cudaGLGetDevices in WSL2 causes error CUresult.CUDA_ERROR_OPERATING_SYSTEM 304

Hi! I am struggling with cuda GL functions in WSL2. The API is accessed in python via cuda-bindings and GL context is created by pylget. Minimal code for reproducing the problem:

import pyglet
from cuda.bindings import driver, runtime

window = pyglet.window.Window()

context = pyglet.gl.current_context
assert(context is not None)

err = driver.cuInit(0)
err, cuDevice = driver.cuDeviceGet(0) 
print(err, err.value, cuDevice)

err, num_devices, device_lst = driver.cuGLGetDevices(1, driver.CUGLDeviceList.CU_GL_DEVICE_LIST_ALL)
print(err, err.value, num_devices, device_lst)

I have tried with toolkit versions 12.4 and 12.8 in WSL2, Windows 11 and Ubuntu 24.04 (different host). cuda-bindings were installed in the proper matching version. Also, drivers were updated on all machines (576.02). On native Win11/Linux, the code runs without a problem. In WSL, the cuGLGetDevices fails.

Do you have any recommendations for me?

Best regards, Harald

1 Like