创建新的mamba(conda)环境时,我只获得Pytorch的CPU包。有谁知道如何确保/强制GPU版本?
即使我安装的第一件事是 cudatoolkit,它也会不断获取 CPU 包。我尝试了 11.6 和 11.3 版本,没有任何变化。
这是我使用的命令:
mamba install pytorch torchvision torchaudio -c pytorch -c conda-forge
+ pytorch 1.13.0 py3.9_cpu_0 pytorch/win-64 145MB
+ pytorch-mutex 1.0 cpu pytorch/noarch 3kB
+ requests 2.28.1 pyhd8ed1ab_1 conda-forge/noarch Cached
+ tbb 2021.6.0 h91493d7_1 conda-forge/win-64 178kB
+ torchaudio 0.13.0 py39_cpu pytorch/win-64 5MB
+ torchvision 0.14.0 py39_cpu pytorch/win-64 7MB
在你问之前:我的 GPU 可用,并且在其他环境中我成功地将 Pytorch 与 GPU 结合使用。
最佳答案
您使用的命令是PyTorch文档官方推荐的命令。
失败似乎是由于 conda-forge 最近出现了新版本的 Pytorch (1.13),并且 GPU 版本似乎存在一些依赖性问题 ( https://anaconda.org/pytorch/pytorch/files )。
不幸的是,似乎没有一种方法可以指定要安装 GPU 版本。默认似乎是安装最新版本,如果 GPU 不工作则回退到 CPU。就您而言,您更关心 GPU 支持,而不是最新的 Pytorch 版本。
解决方案是指定 pytorch==1.12.1
正如您在评论中所说:
mamba install pytorch==1.12.1 torchvision torchaudio -c pytorch -c conda-forge
这是我尝试使用 GPU 强制使用 Pytorch 1.13 时遇到的错误:
❯ mamba create -n testtorch pytorch=1.13=py3.10_cuda11.6_cudnn8_0 torchvision torchaudio cudatoolkit -c pytorch/noarch -c pytorch/win-64 -c conda-forge/win-64 -c conda-forge/noarch --override-channels -d
...
Looking for: ['pytorch==1.13=py3.10_cuda11.6_cudnn8_0', 'torchvision', 'torchaudio', 'cudatoolkit']
pytorch/noarch Using cache
pytorch/win-64 Using cache
conda-forge/win-64 Using cache
conda-forge/noarch Using cache
Encountered problems while solving:
- nothing provides cuda 11.6.* needed by pytorch-cuda-11.6-h867d48c_0
我在这里做了一份 Pytorch 错误报告:https://github.com/pytorch/pytorch/issues/87991
要安装具有 GPU 支持的版本 1.13.0,请运行:
conda install pytorch=1.13.0 torchvision torchaudio pytorch-cuda=11.6 -c pytorch -c nvidia
关于python - 新的曼巴环境强制 torch CPU,我不知道为什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74234628/