PyCuda can't find DLL
I'm trying to do some interop between pycuda and OpenGL, however, if I try to create a context using
import pycuda.gl.autoinit
It fails with this error message:
import pycuda._driver as _drv
ImportError: DLL load failed while importing _driver: The specified module could not be found.
System specs:
> nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Sun_Feb_14_22:08:44_Pacific_Standard_Time_2021
Cuda compilation tools, release 11.2, V11.2.152
Build cuda_11.2.r11.2/compiler.29618528_0
Windows 10, Python 3.9 Newest Nvidia drivers.
Cuda added itself to PATH, CUDA_PATH, and CUDA_PATH_V11_2
If i just try to import import pycuda.gl as cuda_gl
It tells me PyCUDA was compiled without GL extension support Do i have to build from source to enable GL?
This seems to have something to do with #213. The suggested fix of adding CUDA_PATH to the dll directory seems to work. Maybe pycuda can do this automatically?
Maybe pycuda can do this automatically?
It certainly tries to:
https://github.com/inducer/pycuda/blob/29466d4e93ec20a81ce2534327aed24903c3a2e2/pycuda/driver.py#L13-L59
Could you investigate what's happening with that code on your system?
This seems to be a problem with the order in which things are executed. When you call
from pycuda.gl import autoinit
it will first call the init.py file, before anything else! init.py tries to import this:
import pycuda._driver as _drv
however since neither autoinit from pycuda nor autoinit from pycuda.gl have run it fails. Either by calling
from pycuda import autoinit or calling _add_cuda_libdir_to_dll_path in __init__.py this would probably be fixed.
Working example here:
>>> import moderngl
>>> ctx = moderngl.create_standalone_context()
>>> from pycuda import autoinit
>>> from pycuda.gl import autoinit
>>>
I ran into the same issue today. Can pycuda import autoinit by default?