Importing the numpy C-extensions failed.

使用cuda加速时候出现了一堆出错,然后调试的时候发现导入torch都报错了,错误信息如下:

  • errorinfo:

Traceback (most recent call last) File
“E:\anacanda\envs\pytorch\lib\site-packages\numpy\core_init_.py”,
line 22, in
from . import multiarray File “E:\anacanda\envs\pytorch\lib\site-packages\numpy\core\multiarray.py”,
line 12, in
from . import overrides File “E:\anacanda\envs\pytorch\lib\site-packages\numpy\core\overrides.py”,
line 7, in
from numpy.core._multiarray_umath import ( ImportError: DLL load failed: 找不到指定的模块。

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File
“E:/PyCharm/workspace/My_cGAN/cgan.py”, line 1, in
import torch File “E:\anacanda\envs\pytorch\lib\site-packages\torch_init_.py”, line
190, in
from torch.C import * File "E:\anacanda\envs\pytorch\lib\site-packages\numpy_init.py", line
140, in
from . import core File “E:\anacanda\envs\pytorch\lib\site-packages\numpy\core_init_.py”,
line 48, in
raise ImportError(msg) ImportError:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  • The Python version is: Python3.7 from
    “E:\anacanda\envs\pytorch\python.exe” * The NumPy version is:
    “1.19.5”

and make sure that they are the versions you expect. Please carefully
study the documentation linked above for further help.

Original error was: DLL load failed: 找不到指定的模块。

Process finished with exit code 1

  • 翻译

回溯(最近一次调用最后一次):
文件“E:\anacanda\envs\pytorch\lib\site-packages\numpy\core_init_.py”,第
22 行,在 中
从 。导入多阵列 文件“E:\anacanda\envs\pytorch\lib\site-packages\numpy\core\multiarray.py”,第
12 行,
从 。导入覆盖 文件“E:\anacanda\envs\pytorch\lib\site-packages\numpy\core\overrides.py”,第
7 行,在 中
从 numpy.core._multiarray_umath 导入( ImportError: DLL load failed: 找不到指定的模块。

在处理上述异常的过程中,又发生了一个异常:

回溯(最近一次调用最后一次):
中的文件“E:/PyCharm/workspace/My_cGAN/cgan.py”,第 1 行
进口火炬 文件“E:\anacanda\envs\pytorch\lib\site-packages\torch_init_.py”,第 190
行,在 中
从 torch.C 导入 * 文件“E:\anacanda\envs\pytorch\lib\site-packages\numpy_init.py”,第 140
行,在 中
从 。进口核心 文件“E:\anacanda\envs\pytorch\lib\site-packages\numpy\core_init_.py”,第
48 行,在 中
引发导入错误(味精) 导入错误:

重要提示:请阅读本文以获取有关如何解决此问题的建议!

导入 numpy C 扩展失败。此错误可能发生在 很多原因,通常是由于您的设置问题或 NumPy 的方式 安装。

我们在以下位置汇总了一些常见原因和故障排除提示:

https://numpy.org/devdocs/user/troubleshooting-importerror.html

请注意并检查以下内容:

  • Python 版本为:Python3.7 from “E:\anacanda\envs\pytorch\python.exe”
  • NumPy 版本为:“1.19.5”

并确保它们是您期望的版本。 请仔细研究上面链接的文档以获得进一步的帮助。

原始错误为:DLL load failed: 找不到指定的模块。

进程以退出代码 1 结束

提取信息为:
Importing the numpy c-extensions failed 导入 numpy C 扩展失败。

所以重新安装了一次numpy,解决方案:

pip uninstall -y numpy

pip uninstall -y setuptools

pip install setuptools

pip install numpy

Importing the numpy C-extensions failed._第1张图片
可以重新导入torch了。

参考:https://blog.csdn.net/kaede0v0/article/details/115557457

你可能感兴趣的:(Debug,torch)