【问题标题】:How to change the pytorch version in Google colab如何在 Google colab 中更改 pytorch 版本
【发布时间】:2021-10-24 10:15:14
【问题描述】:

我需要在google 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

更重要的是,当我尝试时

pip uninstall torch

colab 告诉我你要卸载 pytorch-1.0.0

它是怎么发生的?

【问题讨论】:

    标签: python pytorch google-colaboratory


    【解决方案1】:

    首先,你必须运行

    !pip uninstall torch
    

    然后,当提示您输入Proceed (y/n)? 时,单击正在打印输出的背景,按y,然后单击Enter。这将卸载 torch,大约需要 5 分钟。

    那么,你必须

    !pip install torch==1.0.0
    

    最后

    import torch
    torch.__version__
    # '1.0.0'
    

    【讨论】:

    • 只需使用!pip uninstall torch -y 即可跳过确认提示。
    猜你喜欢
    • 1970-01-01
    • 2019-01-29
    • 2022-11-23
    • 2021-01-30
    • 2020-07-29
    • 2020-11-19
    • 2019-05-15
    • 2023-03-04
    • 2018-11-10
    相关资源
    最近更新 更多