Anaconda更新时总是想把我的GPU Pytorch版本替换为CPU Pytorch版本

标签 anaconda pytorch conda

我有一个新安装的Anaconda3(版本2020.02)环境,并且通过命令conda install pytorch torchvision cudatoolkit=10.2 -c pytorch安装了Pytorch GPU版本。我已经验证我的 Pytorch 确实在 GPU 上运行良好。

但是,每当我通过 conda update --all 更新 Anaconda 时,总会显示以下消息:

The following packages will be SUPERSEDED by a higher-priority channel:

  pytorch            pytorch::pytorch-1.5.0-py3.7_cuda102_~ --> pkgs/main::pytorch-1.5.0-cpu_py37h9f948e0_0

也就是说,它总是想把我的GPU版本的Pytorch替换成CPU版本的。我试过,如果继续更新,会安装CPU版本的Pytorch,而我之前在GPU上的Pytorch代码无法再运行。我还尝试了命令 conda update --all --no-channel-priority 但该消息仍然显示。

据我所知,我从未修改过 Anaconda channel 或添加自定义 channel 。我怎样才能摆脱这个消息?

最佳答案

发生这种情况是因为,默认情况下,conda 更喜欢来自较高优先级 channel 的包,而不是来自较低优先级 channel 的任何版本。 -- conda docs

您可以通过更改.condarc中的顺序将pytorch channel 的优先级设置为高于默认 channel 来解决此问题 -- more here

channels:
  - pytorch
  - defaults
  - conda-forge

channel_priority: true

或者您可以通过指定选项来升级它:

conda update --all -c pytorch

关于Anaconda更新时总是想把我的GPU Pytorch版本替换为CPU Pytorch版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62630186/

相关文章:

python - Jupyter notebook 升级后变为 RTL

tensorflow - 为什么当我增加批量大小时 tensorflow GPU 内存使用量会减少?

python - 在训练期间固定神经网络中的一部分权重

numpy - 安装 `defaults` 包时如何比 `conda-forge` numpy 更喜欢 `conda-forge` numpy

python - 为什么 Blender 没有检测到来自 Anaconda 的 python 包?

python - TensorFlow : NotFoundError: Resource AnonymousIterator Error

python - 在 Windows 上将 Anaconda 的根 Python 更新为较新的次要版本没有任何作用

python-3.x - "no module named torch"。但是在 Ubuntu 18.04.02 服务器版中安装了带有 conda 的 pytorch 1.3.0

python - Makefile 无法使用 `conda activate`

python - 如何让我的 python 可执行文件找到我的网站包