由于缺少 DLL 文件,CuPy 导入失败,尽管它出现在我的目录中

问题描述

我正在尝试使用 cuPy 来加速我的 python 代码中的一些后台 numpy 操作,但是当我尝试导入 cupy 时,我被告知 DLL 加载失败并且找不到模块,cupy_backends.cuda.libs import nvrtc。 (具体错误见文末)

我尝试了几乎所有错误消息提示内容。我检查了我的cupy和cuda版本,它们是cupy-cuda111==8.4.0,我也安装了Cuda 11.2。我在 Spyder 3 上运行 Windows 10 和 Python 3.7.6。我尝试通过 pip uninstall 卸载cupy,希望能正确重新安装,但它只是挂起,从不卸载软件包。

当我通过文件资源管理器手动搜索时,我似乎找到了要查找的文件。 (下图)

file explorer showing the missing file in question

我在处理此类事情时相当缺乏经验,因此将不胜感激。整个错误消息和跟踪复制如下:

import cupy as cp
Traceback (most recent call last):

  File "C:\ProgramData\Anaconda3\lib\site-packages\cupy\__init__.py",line 20,in <module>
    from cupy import core  # NOQA

  File "C:\ProgramData\Anaconda3\lib\site-packages\cupy\core\__init__.py",line 1,in <module>
    from cupy.core import core  # NOQA

  File "cupy\core\core.pyx",in init cupy.core.core

  File "C:\ProgramData\Anaconda3\lib\site-packages\cupy\cuda\__init__.py",line 5,in <module>
    from cupy.cuda import compiler  # NOQA

  File "C:\ProgramData\Anaconda3\lib\site-packages\cupy\cuda\compiler.py",line 14,in <module>
    from cupy_backends.cuda.libs import nvrtc

ImportError: DLL load Failed: The specified module Could not be found.


The above exception was the direct cause of the following exception:

Traceback (most recent call last):

  File "<ipython-input-1-e011b0e859cc>",in <module>
    import cupy as cp

  File "C:\ProgramData\Anaconda3\lib\site-packages\cupy\__init__.py",line 41,in <module>
    raise ImportError(_msg) from e

ImportError: CuPy is not correctly installed.

If you are using wheel distribution (cupy-cudaXX),make sure that the version of CuPy you installed matches with the version of CUDA on your host.
Also,confirm that only one CuPy package is installed:
  $ pip freeze

If you are building CuPy from source,please check your environment,uninstall CuPy and reinstall it with:
  $ pip install cupy --no-cache-dir -vvvv

Check the Installation Guide for details:
  https://docs.cupy.dev/en/latest/install.html

original error: DLL load Failed: The specified module Could not be found.

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)