【问题标题】:while importing torch- shows - [WinError 126] The specified module could not be found导入手电筒时 - 显示 - [WinError 126] 找不到指定的模块
【发布时间】:2021-02-01 02:18:39
【问题描述】:

我尝试使用安装 python 火炬

  !pip install torch 

但是我得到了错误OSError: [WinError 126] The specified module could not be found

然后我尝试了

pip install torch -f https://download.pytorch.org/whl/torch_stable.html

运行日志如下,

然后我通过下面的命令安装了torch来安装torch的CPU版本。

pip install torch==1.7.1+cpu torchvision==0.8.2+cpu torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html

然后,当我尝试通过命令进行测试时,

import torch
print(torch.__version__)

在 Spyder 中,它仍然无法识别,

但是,在 python.exe 中,它可以识别并提供正确的输出。

【问题讨论】:

  • 你的电脑有支持 CUDA 的 GPU 吗?
  • 我认为我没有启用 CUDA 的 GPU,因为我的机器具有非 NVIDIA 的 RADEON VEGA 3 显卡。

标签: python pytorch


【解决方案1】:

好的,问题是您尝试在未启用 cuda 的计算机上安装 Pytorch 的 cuda 版本。你可以找到类似的问题here。你必须像这样下载pytorch的cpu版本

pip install torch==1.7.1+cpu torchvision==0.8.2+cpu torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html

【讨论】:

  • 非常感谢您的回复。我在实施解决方案后更新了帖子。如果可以的话,请看看。现在,简而言之,它无法从 Spyder 识别,但它可以从 Python.exe 识别。
  • 您的 spyder 在 conda 环境中吗?因为那样你就需要使用 conda 来安装它。
猜你喜欢
  • 2021-10-22
  • 2020-08-17
  • 1970-01-01
  • 2020-10-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-21
  • 2020-10-24
相关资源
最近更新 更多