记录在Windows上运行PyTorch时遇到的错误
[WinError 1114] 动态链接库(DLL)初始化例程失败。 Error loading "D:\Python\Python310\lib\site-packages\torch\lib\c10.dll" or one of its dependencies
由于我的电脑没有Nvidia显卡。在命令行运行以下命令查看是否支持Nvidia显卡
nvidia-smi
所以只能改用 CPU-only 版本 的 PyTorch
# 卸载现有版本
pip uninstall torch torchvision torchaudio
# 安装 CPU 版本(官方命令)
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
接着,检查相关依赖
PyTorch 编译时依赖 MSVC 运行库。缺少它会导致 c10.dll 初始化失败。
下载并安装 x64 版本 的 VC++ Redist:
- https://aka.ms/vs/17/release/vc_redist.x64.exe
安装后重启电脑再试。
重装后可以在控制面板 - 程序查看到以下安装
Microsoft Visual C++ Redistributable(特别是 2015–2022 版本)
然后再运行PyTorch就不会报错啦
初始化例程失败&spm=1001.2101.3001.5002&articleId=155531141&d=1&t=3&u=f7c9eaff30c94a35844f23c50b73832d)
8426

被折叠的 条评论
为什么被折叠?



