python - 来自 torch._C import * ImportError : DLL load failed: The specified module could not be found

标签 python machine-learning pytorch torch

我正在尝试使用 python 3.5 在我的 Windows 机器中import torch。 (仅限 CPU)(点) 我已按照 official website 中给出的步骤进行操作.

当我尝试导入 torch 时,出现错误:

from torch._C import *
ImportError: DLL load failed: The specified module could not be found.

我查过from torch._C import * (ImportError: DLL load failed: The specified module could not be found.ModuleNotFoundError: No module named 'torch._C'并按照他们的指示进行操作,错误仍然存​​在。

总回溯:

Traceback (most recent call last):
File "D:\CFPS.py", line 1, in <module>
import torch
File "C:\Program Files (x86)\Python35\lib\site-packages\torch\__init__.py", 
line 78, in <module>
from torch._C import *
ImportError: DLL load failed: The specified module could not be found.
[Finished in 0.6s]

有办法解决这个问题吗?

最佳答案

我也遇到了同样的问题。 Pytorch 似乎需要 openmp,但这不是 PIP 分发的一部分。

如果您通过 Anaconda 安装 Pytorch,则 Anaconda 安装包括 openmp,因此这个问题就会消失。

要用pip解决这个问题,你可以 pip 安装英特尔-openmp

但您仍然需要将 openmp 二进制文件从 Python\Library\bin 复制到 Python\Lib\site-packages\torch\lib

这是 pytorch 问题的链接

pytorch issue

关于python - 来自 torch._C import * ImportError : DLL load failed: The specified module could not be found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50612899/

相关文章:

python - scikit-learn 中 PCA 的质量

python - 多类文本分类期间 xgboost sklearn 中的 feature_names 不匹配

python - 如何在 PyTorch 中标准化图像

python - mongokit 索引不起作用

python - 当我释放 ImageButton 时调用 .py 脚本时出现语法错误

python - 在 Pygame 中加载与角色 Sprite 碰撞时爆炸的图像

machine-learning - 计算训练中迭代的纪元数?

python - 使用 Pandas 计算一段时间内创建的观测值数量

r - Azure ML Studio 上无法打开连接错误(运行 R 脚本)

python - 导入错误: Using the `Trainer` with `PyTorch` requires `accelerate`