installation - 导入手电筒 OSError:[WinError 127]
问题描述
我正在尝试安装torch-gpu。我已经安装了 cuda 11.1 并通过命令安装了 torchpip3 install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio===0.8.1 -f https://download.pytorch.org/whl/torch_stable.html
这太愚蠢了,但在导入过程中出现以下错误OSError: [WinError 127] Error loading "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\torch\lib\c10_cuda.dll" or one of its dependencies.
。
c10_cuda.dll在那个目录下,我搞了好几天还是解决不了。我需要torch-gpu,这就是使用这种可能性的关键,请不要评论“安装torch-cpu”。
解决方案
自己回答问题
要安装torch-gpu,应该:
检查最新(或不是)版本和兼容的 cuda 版本:https ://pytorch.org/get-started/locally/ ,此时它是 11.1。
在 1) 步骤 ( https://developer.nvidia.com/cuda-toolkit-archive )中下载并安装已建立版本的 cuda 。这取决于 gpu,如果有任何问题,您可能会下载旧版本或者您已经安装了它?然后您可以在命令行中手动检查版本:
nvcc --version
.使用 1) 步骤中的命令安装 Torch(例如
conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch -c conda-forge
)检查安装成功为
import torch torch.cuda.is_available()
.
就我而言,我必须删除以前安装的手电筒pip uninstall torch
并conda clean -a
用于安装才能成功结束。
推荐阅读
- excel - VBA粘贴基于行,列号
- svg.js - 如何使用我自己的 id 来识别元素
- nlp - 如何在两个不同的文本文件(两个文档)中找到语义相似的段落
- r - 我在 REML 中的随机效应之一导致错误
- reactjs - 使用 Redux React Hooks 中的 useMappedState,API 响应后组件不会重新渲染
- javascript - 在 tableSorter 2.0 中对重音字符进行排序
- machine-learning - 为什么全卷积网络先平稳后学习?
- python - 当我在 IDE (Pycharm) 上运行它时程序可以工作,但当我在终端上运行它时不能?
- django - 视图没有返回 HttpResponse 对象。它返回无
- image - 在移动设备上调整图像大小的问题 (PHP)