VScode 配置 conda ImportError: DLL load failed: 找不到指定的模块问题。(南科大深度Seting Up the ProgrammingEnvironment)
摘要:安装PyTorch时出现numpy导入错误,提示MKL服务包缺失和DLL加载失败。问题源于通过conda安装依赖包导致兼容性问题。解决方法是先用pip卸载相关包,再通过pip重新安装。经验表明,使用conda直接安装容易出现异常,推荐优先使用pip进行包管理。该问题涉及numpy、PyTorch等科学计算包的依赖冲突。
如图:
D:\anaconda3\envs\cs324\lib\site-packages\numpy\__init__.py:148: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
from . import _distributor_init
Traceback (most recent call last):
File "D:\anaconda3\envs\cs324\lib\site-packages\numpy\core\__init__.py", line 22, in <module>
from . import multiarray
File "D:\anaconda3\envs\cs324\lib\site-packages\numpy\core\multiarray.py", line 12, in <module>
from . import overrides
File "D:\anaconda3\envs\cs324\lib\site-packages\numpy\core\overrides.py", line 7, in <module>
from numpy.core._multiarray_umath import (
ImportError: DLL load failed: 找不到指定的模块。
原因:使用指令安装导致:
# Please run the command in Anaconda Powershell Prompt or Anaconda Prompt.
conda activate cs324
# cpu only
conda install pytorch torchvision cpuonly -c pytorch
# gpu cuda 10.1
conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
# when you install PyTorch, numpy will be installed automatically.
# Now you only need to install other packages.
conda install matplotlib
conda install scipy
conda install scikit-learn
conda install jupyter
用pip uninstall 下载的包之后,再用pip install之后就好了。
从conda指令直接安装往往结果很奇怪。
更多推荐
所有评论(0)