Is there way to change runtime type in Google Colab using python

Viewed 1695
2 Answers

You can read the notebook.ipynb into json string. Edit it, the overwrite it or create a new notebook file.

It may be easier to download it, edit it with a text editor, then upload and open it again.

For example, a notebook.ipynb with GPU runtime will look like this

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

To change to Python 2.7, you change "name":"python2".

To change to GPU runtime, you add "accelerator": "GPU".

You can do this by hand (edit it in a text editor) or by Python (read json to dict, replace, overwrite, re-open).

You can change run time type by going

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

Related