如何在Google Colab中更改PyTorch版本。

5
我需要在谷歌colab中更改pytorch版本,因此我安装了anaconda。
%%bash
MINICONDA_INSTALLER_SCRIPT=Miniconda3-4.5.4-Linux-x86_64.sh
MINICONDA_PREFIX=/usr/local
wget https://repo.continuum.io/miniconda/$MINICONDA_INSTALLER_SCRIPT
chmod +x $MINICONDA_INSTALLER_SCRIPT
./$MINICONDA_INSTALLER_SCRIPT -b -f -p $MINICONDA_PREFIX

import sys
_ = (sys.path
        .append("/usr/local/lib/python3.6/site-packages"))

然后

!conda install  pytorch==1.0.0 torchvision==0.2.1 cuda100 -c pytorch --yes

但是当我

import torch
torch.__version__

这是1.9+cuda120版本的it技术。

此外,当我尝试时...

pip uninstall torch

Colab告诉我是否要卸载PyTorch-1.0.0。

这是怎么发生的?

1个回答

4

首先,你需要运行

!pip uninstall torch -y
-y 是为了跳过提示请求。这将卸载 torch,需要大约 5 分钟左右时间。

然后,你需要

!pip install torch==1.0.0

最后

import torch
torch.__version__
# '1.0.0'

1
只需使用 !pip uninstall torch -y 即可跳过确认提示。 - Ethan T

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接