【问题标题】:Is there way to change runtime type in Google Colab using python有没有办法使用 python 在 Google Colab 中更改运行时类型
【发布时间】:2020-11-15 21:42:55
【问题描述】:

Google Colab Runtime Selection

有没有办法在 Google Colab 中使用 python 代码而不是使用 GUI 来更改运行时类型,如图所示。

【问题讨论】:

标签: python computer-science google-colaboratory


【解决方案1】:

您可以将 notebook.ipynb 读入 json 字符串。编辑它,覆盖它或创建一个新的笔记本文件。

下载它可能更容易,用文本编辑器编辑它,然后上传并再次打开它。

例如,带有 GPU 运行时的 notebook.ipynb 将如下所示

{
    "nbformat": 4,
    "nbformat_minor": 0,
    "metadata": {
        "colab": {...},
        "kernelspec": {
            "name": "python3",
            "display_name": "Python 3"
        },
        "accelerator": "GPU"
    },
    "cells": [...]
}

要更改为 Python 2.7,请更改 "name":"python2"。

要更改为 GPU 运行时,请添加 "accelerator": "GPU"。

您可以手动(在文本编辑器中编辑)或通过 Python(读取 json 以 dict、替换、覆盖、重新打开)来执行此操作。

【讨论】:

  • 我的问题是如何改变运行时类型:GPU,TPU using Python
  • 我添加了更多细节。
【解决方案2】:

你可以通过去改变运行时间类型

Runtime -> Change run time type -> GPU,TPU

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-09-29
    • 1970-01-01
    • 2020-11-10
    • 1970-01-01
    • 2023-03-04
    • 2021-06-22
    • 2020-09-02
    • 1970-01-01
    相关资源
    最近更新 更多