import torch
报错,信息如下:
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库版本符合如下要求:
mkl<=2021.4.0,>=2021.1.1 (from torch==2.3.0)
可能是由于之前别的任务需求中安装了最新版本的mkl库。
解决方法:
更新安装依赖
pip install torch==2.3.0 torchvision==0.18.0 torchaudio==2.3.0 --index-url https://download.pytorch.org/whl/cu118
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
标签:WinError,OSError,torch,envs,mkl,python,2.3,packages From: https://www.cnblogs.com/jiangkejie/p/18470858