PyCUDA——导入 pycuda.driver 时出现问题
- Windows 10
- Python 3.8
- CUDA 11.5
我已经从这个文件安装了我认为匹配的 pycuda: pycuda-2021.1+cuda115-cp38-cp38-win_amd64.whl
这个简单的示例失败
import pycuda.driver as drv
drv.init()
print("Detected {} CUDA devices".format(drv.Device.count()))
并出现以下错误:
Traceback (most recent call last):
File "C:/University of Arizona/weeds/tests/cuda-summary.py", line 5, in <module>
import pycuda.driver as drv
File "C:\Users\evan\AppData\Local\Programs\Python\Python38\lib\site-packages\pycuda\driver.py", line 65, in <module>
from pycuda._driver import * # noqa
ImportError: DLL load failed while importing _driver: The specified procedure could not be found.
- NVCC 在我的路径中
- 添加 os.add_dll_directory(os.path.join(os.environ['CUDA_PATH'], ' bin')) 没有效果
该脚本在我的 Jetson Nano 上工作得很好 关于
如何克服这个问题有什么想法吗?我搜索并尝试了几种解决方案。
- Windows 10
- Python 3.8
- CUDA 11.5
I've installed what I believe to be a matching pycuda from this file:
pycuda-2021.1+cuda115-cp38-cp38-win_amd64.whl
This simple example fails
import pycuda.driver as drv
drv.init()
print("Detected {} CUDA devices".format(drv.Device.count()))
With this error:
Traceback (most recent call last):
File "C:/University of Arizona/weeds/tests/cuda-summary.py", line 5, in <module>
import pycuda.driver as drv
File "C:\Users\evan\AppData\Local\Programs\Python\Python38\lib\site-packages\pycuda\driver.py", line 65, in <module>
from pycuda._driver import * # noqa
ImportError: DLL load failed while importing _driver: The specified procedure could not be found.
- NVCC is in my path
- Adding os.add_dll_directory(os.path.join(os.environ['CUDA_PATH'], 'bin')) has no effect
The script works just fine on my Jetson Nano
Any ideas on how to get past this? I've searched and tried several solutions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这很奇怪,但更新 Nvidia 显示驱动程序解决了我的问题。
但就我而言,我的 PC 上使用相同版本的 Windows、Python、CUDA 和 PyCuda 时没有出现问题。当启动由 PyInstaller 打包的 exe 时,该问题出现在不同的 Windows 10 计算机上。因此,更新显示驱动程序是这台机器的修复方法。
It is quite strange, but updating the Nvidia display driver fixed the issue for me.
But in my case there was no issue on my PC with the same versions of Windows, Python, CUDA and PyCuda. The issue appeared on the different Windows 10 machine, when launching the exe, packaged by PyInstaller. So, updating the display driver was the fix for this machine.