[PYTHON] Instructions for connecting Google Colab. To the local runtime in a Windows environment

Basically, it follows the Official HP setting procedure here.

Colaboratory allows you to run code on your local hardware and access your local file system by using Jupyter to connect to your local runtime.

I think that it will be used only when the local PC has a super powerful GPU and you want to run a program with a processing time of more than 12 hours.

It is assumed that Python3.7 is already installed in the Windows 10 environment with the installer brought from https://www.python.org/ (managing the Python virtual environment with virtualenv and virtualenv wrapper). Note: Anaconda is not in use. </ font>

Install Jupyter (main unit) & create configuration file

Open a command prompt and install Jupyter.

Jupyter installation


pip install jupyter

Create a Jupyter configuration file.

Creating a Jupyter configuration file


jupyter notebook --generate-config

The created file is saved in C: \ Users \ xxxx \ .jupyter \ as jupyter_notebook_config.py. It is loaded when Jupyter notebook is started.

Install & enable the extension jupyter_http_over_ws

Install the Jupyter extension jupyter_http_over_ws.

jupyter_http_over_ws installation


pip install jupyter_http_over_ws

** Enable ** jupyter_http_over_ws.

jupyter_http_over_ws activation / execution result


C:\Users\xxxx>jupyter serverextension enable --py jupyter_http_over_ws
Enabling: jupyter_http_over_ws
- Writing config: C:\Users\xxxx\.jupyter
    - Validating...
      jupyter_http_over_ws 0.0.7 ok

Edit configuration file

Edit the Jupyter ** config file **. Since it is commented out with #, cancel it and set as follows.

jupyter_notebook_config.py


#  Takes precedence over allow_origin_pat.
c.NotebookApp.allow_origin = 'https://colab.research.google.com'

## The port the notebook server will listen on.
c.NotebookApp.port = 8888

## The number of additional ports to try if the specified port is not available.
c.NotebookApp.port_retries = 0

Launch Jupyter Notebook

Start Jupyter Notebook.

Launch Jupyter Notebook


C:\Users\xxxx>jupyter notebook
jupyter_http_over_ws extension initialized. Listening on /http_over_websocket
[I 09:33:03.054 NotebookApp] Serving notebooks from local directory: C:/Users/xxxx/Documents/Python
[I 09:33:03.055 NotebookApp] The Jupyter Notebook is running at:
[I 09:33:03.055 NotebookApp] http://localhost:8888/?token=afd9b93664......................................
[I 09:33:03.055 NotebookApp]  or http://127.0.0.1:8888/?token=afd9b93664......................................
[I 09:33:03.055 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 09:33:03.396 NotebookApp]

    To access the notebook, open this file in a browser:
        file:///C:/User/xxxx/AppData/Roaming/jupyter/runtime/nbserver-3744-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=afd9b93664......................................
     or http://127.0.0.1:8888/?token=afd9b93664......................................

Copy "http: // localhost: 8888 /? Token = afd9b93664 ..." output at this time.

Connect to Google Colab.

Access & log in to Google Colab. in your web browser (Chrome) and open the appropriate notebook.

Click Connect ▼ at the top right of the screen and select Connect to Local Runtime .... fig1.png

A dialog will be displayed, so check the notes carefully and paste the copied "http: // localhost: 8888 /? Token = afd9b93664 ..." in the Backend URL field. Add it and click Connect to complete. fig2.png

It is successful if the status is Connected (local) as shown below.

fig3.png

Now you can use it without being bound by the 90-minute rule or the 12-hour rule.

Recommended Posts

Instructions for connecting Google Colab. To the local runtime in a Windows environment
How to run AutoGluon in Google Colab GPU environment
How to use jupyter lab in Windows 10 local environment
I tried the super-resolution algorithm "PULSE" in a Windows environment
Create a Python environment for professionals in VS Code on Windows
[For beginners] How to implement O'reilly sample code in Google Colab
[Introduction to Python] How to use the in operator in a for statement?
LINEbot development, I want to check the operation in the local environment
Solution to the problem that Ctrl + z cannot be used in Powershell in Docker for windows environment (provisional)
Change the list in a for statement
Numpy 1.19.4 error RuntimeError: The current Numpy installation fails to pass a sanity check due to a bug in the windows runtime.
How to run a quickstart for Google Cloud Text-to-Speech .NET in Unity
Switch the module to be loaded for each execution environment in Python
How to copy and paste the contents of a sheet in Google Spreadsheet in JSON format (using Google Colab)
What I was addicted to when creating a web application in a windows environment
I want to use Python in the environment of pyenv + pipenv on Windows 10
How to get the notebook name you are currently using in Google Colab
[AWS] Let's run a unit test of Lambda function in the local environment
I searched for the skills needed to become a web engineer in Python
Build a local development environment with WSL + Docker Desktop for Windows + docker-lambda + Python
How to install the deep learning framework Tensorflow 1.0 in the Anaconda environment of Windows
Set a fixed IP in the Linux environment
How to display videos inline in Google Colab
Explaining how to make LINE BOT in the world's easiest way (2) [Preparing a bot application in a local environment with Django in Python]
How to set up a Google Colab environment with Coursera's advanced machine learning courses
I tried to build an environment with WSL + Ubuntu + VS Code in a Windows environment
Try to make a blackjack strategy by reinforcement learning (② Register the environment in gym)
Find a guideline for the number of processes / threads to set in the application server
Build a local development environment for Laravel6.X on Mac
Register a task in cron for the first time
The shortest route to get a cultural fish environment
[For beginners] Install the package in the Anaconda environment (Janome)
Procedure for building a CDK environment on Windows (Python)
How to create a local repository for Linux OS
Convenient to use matplotlib subplots in a for statement
How to build a development environment for TensorFlow (1.0.0) (Mac)
When you want to plt.save in a for statement
Fixed a way to force Windows to boot in UEFI
Force luigi to do parallel processing in windows environment
Is it a problem to eliminate the need for analog human resources in the AI era?
Run the program without building a Python environment! !! (How to get started with Google Colaboratory)
How to set up WSL2 on Windows 10 and create a study environment for Linux commands
The shortest memo for building a python environment that takes less than 5 minutes to work.
How to connect to Cloud SQL PostgreSQL on Google Cloud Platform from a local environment with Java
A story that makes it easier to see Model debugging in the Django + SQLAlchemy environment
Send a message from the server to your Chrome extension using Google Cloud Messaging for Chrome
virtualenvwrapper in windows environment
Define a task to set the fabric env in YAML
A memorandum to register the library written in Hy in PyPI
Display "Hello World" created in the local environment on the web
Create a local scope in Python without polluting the namespace
Check the operation of Python for .NET in each environment
Change the standard output destination to a file in Python
How to use VS Code in venv environment on windows
A note for embedding the scripting language in a bash script
Building a development environment for Android apps-creating Android apps in Python
A simple way to avoid multiple for loops in Python
How to define multiple variables in a python for statement
Double-click ipynb in windows + anaconda environment to open with jupyter-notebook
Put the lists together in pandas to make a DataFrame
A note on how to load a virtual environment in PyCharm