import torch OSError: [WinError 126] 找不到指定的模块。

1
import torch

报错,信息如下:

1
OSError: [WinError 126] 找不到指定的模块。 Error loading "C:\Anaconda3\envs\python-3.11\Lib\site-packages\torch\lib\shm.dll" or one of its dependencies.

我的pytorch版本

pip install torch==2.3.0 torchvision==0.18.0 torchaudio==2.3.0 --index-url https://download.pytorch.org/whl/cu118

 

原因:mkl库以及intel-openmp库与pytorch版本不匹配,对于torch2.3.0版本要求mkl库版本符合如下要求:

1
mkl<=2021.4.0,>=2021.1.1 (from torch==2.3.0)

 

可能是由于之前别的任务需求中安装了最新版本的mkl库。

 

 

解决方法:

更新安装依赖

1
pip install torch==2.3.0 torchvision==0.18.0 torchaudio==2.3.0 --index-url https://download.pytorch.org/whl/cu118

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<br>Looking in indexes: https://download.pytorch.org/whl/cu118
Requirement already satisfied: torch==2.3.0 in c:\anaconda3\envs\python-3.11\lib\site-packages (2.3.0+cu118)
Requirement already satisfied: torchvision==0.18.0 in c:\anaconda3\envs\python-3.11\lib\site-packages (0.18.0)
Requirement already satisfied: torchaudio==2.3.0 in c:\anaconda3\envs\python-3.11\lib\site-packages (2.3.0+cu118)
Requirement already satisfied: filelock in c:\anaconda3\envs\python-3.11\lib\site-packages (from torch==2.3.0) (3.14.0)
Requirement already satisfied: typing-extensions>=4.8.0 in c:\anaconda3\envs\python-3.11\lib\site-packages\setuptools\_vendor (from torch==2.3.0) (4.12.2)
Requirement already satisfied: sympy in c:\anaconda3\envs\python-3.11\lib\site-packages (from torch==2.3.0) (1.12.1)
Requirement already satisfied: networkx in c:\anaconda3\envs\python-3.11\lib\site-packages (from torch==2.3.0) (3.3)
Requirement already satisfied: jinja2 in c:\anaconda3\envs\python-3.11\lib\site-packages (from torch==2.3.0) (3.1.4)
Requirement already satisfied: fsspec in c:\anaconda3\envs\python-3.11\lib\site-packages (from torch==2.3.0) (2024.6.0)
Collecting mkl<=2021.4.0,>=2021.1.1 (from torch==2.3.0)
  Downloading https://download.pytorch.org/whl/mkl-2021.4.0-py2.py3-none-win_amd64.whl (228.5 MB)
     ---------------------------------------- 228.5/228.5 MB 9.2 MB/s eta 0:00:00
Requirement already satisfied: numpy in c:\anaconda3\envs\python-3.11\lib\site-packages (from torchvision==0.18.0) (1.26.4)
Requirement already satisfied: pillow!=8.3.*,>=5.3.0 in c:\anaconda3\envs\python-3.11\lib\site-packages (from torchvision==0.18.0) (10.3.0)
Collecting intel-openmp==2021.* (from mkl<=2021.4.0,>=2021.1.1->torch==2.3.0)
  Downloading https://download.pytorch.org/whl/intel_openmp-2021.4.0-py2.py3-none-win_amd64.whl (3.5 MB)
     ---------------------------------------- 3.5/3.5 MB 10.4 MB/s eta 0:00:00
Requirement already satisfied: tbb==2021.* in c:\anaconda3\envs\python-3.11\lib\site-packages (from mkl<=2021.4.0,>=2021.1.1->torch==2.3.0) (2021.10.0)
Requirement already satisfied: MarkupSafe>=2.0 in c:\anaconda3\envs\python-3.11\lib\site-packages (from jinja2->torch==2.3.0) (2.1.5)
Requirement already satisfied: mpmath<1.4.0,>=1.1.0 in c:\anaconda3\envs\python-3.11\lib\site-packages (from sympy->torch==2.3.0) (1.3.0)
Installing collected packages: intel-openmp, mkl
  Attempting uninstall: intel-openmp
    Found existing installation: intel-openmp 2023.2.0
    Uninstalling intel-openmp-2023.2.0:
      Successfully uninstalled intel-openmp-2023.2.0
  Attempting uninstall: mkl
    Found existing installation: mkl 2023.2.0
    Uninstalling mkl-2023.2.0:
      Successfully uninstalled mkl-2023.2.0
Successfully installed intel-openmp-2021.4.0 mkl-2021.4.0

  

可以看到对mkl库以及intel-openmp进行了重新安装!!!

intel-openmp 2023.2.0  >>>  intel-openmp-2021.4.0

mkl 2023.2.0 >>> mkl-2021.4.0

 

posted on   那抹阳光1994  阅读(910)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· DeepSeek在M芯片Mac上本地化部署
· 葡萄城 AI 搜索升级:DeepSeek 加持,客户体验更智能
历史上的今天:
2020-10-16 信号的自相关、互相关和协方差
2019-10-16 Hausdorff 距离
2019-10-16 机器学习中的各种 “熵”
2019-10-16 集成学习

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示