How to Connect Google Colab to a Local Runtime

undefined or mostly null.
Search for a command to run...

undefined or mostly null.
You can tell whether a review is professional from the first sentence. One of the most difficult aspects of a great dissertation writing services is providing unique, non-plagiarized material. The website will not rank well if the material is plagiarized. When it comes to selecting the top essay writing service reviews,
2022 Lamborghini Huracán attracts everyone's attention, but strange is the way he attacks the driver's senses
In this series, I will share introductory random articles related to Python, R, data science, and machine learning.
RStudio is the best integrated development environment (IDE) for data science teams that use the R programming language. It includes a syntax-highlighting editor and console alongside plotting, debugging, and workspace management tools. In addition, ...
I wrote this article in December 2023 for an interview screening task and thought to share it today while clearing my drafts for some new content prep, just in case it's still helpful to someone out t

Hey! I’m super excited to announce that I have joined the Secretariat Team at the Digital Public Goods Alliance. In this role, I leverage my passion for open source and technical background to assess DPG applications, provide technical support and ad...

Creative designs have become more important than ever in the software ecosystem today with many industries and end-consumers having several use cases that require them to offer design editing solutions to either designers or end-consumers. Every busi...

With the rise of artificial intelligence (AI) and large language models (LLMs), it has become easier to solve different human problems than ever before. Even consumers with little to no technical expertise can benefit from AI. Humans can now automate...

Some years ago, GitHub introduced the new Profile README feature that allowed GitHub users to pin a markdown file on their profile using a special repository named after their GitHub username. Since then, developers have used this file as a quick por...

Google Colaboratory lets you build "Colab notebooks" on the browser by blending Python executable code with rich text (along with images, HTML, and LaTeX). It is one of the simplest ways to work with Python notebooks, with no configuration required, easy collaboration, and free access to GPUs and TPUs. Unfortunately, while Colab provides access to GPUs, these resources are limited and will eventually run out. For a monthly fee, you can upgrade to Colab Pro or Colab Pro+, which gives you access to more GPUs and memory resources. However, if you're running a minimal collaboratory notebook, you can utilize the alternative option; connecting Google Colab to a local Jupyter runtime to use your local CPU and file storage. In this article, I'll show you how to set up a Jupyter notebook and everything you need to know about connecting to Colab.

The first step is to install Jupyter notebook. I recommend you download and install Anaconda for your operating system of choice. This will also install Python, Jupyter Notebook, and other regularly used data engineering packages. Once Anaconda is installed, you automatically have Jupyter installed.
Alternatively, you can install Jupyter using PIP provided you have Python installed already using the command below:
pip3 install --upgrade pip
pip3 install jupyter
Upon a successful installation, you can launch Anaconda and start a Jupyter server using the GUI or use the command line.
Install the Colab Jupyter HTTP-over-WebSocket extension that allows you to run Jupyter notebooks using a WebSocket to proxy HTTP traffic. You can achieve that using the command below:
pip install --upgrade jupyter_http_over_ws>=0.0.7
Next, enable the extension:
jupyter serverextension enable --py jupyter_http_over_ws
Start a new Jupyter server on port 8888, allowing origin to the Colab domain using the command below:
jupyter notebook \
--NotebookApp.allow_origin='https://colab.research.google.com' \
--port=8888 \
--NotebookApp.port_retries=0
Once the server has started, it will print a backend URL alongside a token for authentication. Kindly copy the entire URL that starts with http://localhost ahead for the next step.

In your Google Colab notebook, click on the toggle button at the top right corner showing the RAM and Disk status bar and select the option "Connect a local runtime" as seen in the screenshots below.


You'll then be asked to enter the backend URL you copied earlier. Enter it and click on the "Connect" button. Now you should be connected successfully to your local machine.


If you're running your own personal notebook, you can as well run them locally using Jupyter notebook. However, suppose you're working on a collaborative notebook or want to take advantage of additional Google Colab features like mounting your Google drive directly into the notebook. In that case, the local runtime setup can be useful when your GPU usage reaches its limit. To avoid security issues, make sure you trust the notebook before connecting locally.
I hope you found this helpful; cheers! 💙