remocolab is a Python module to allow remote access to Google Colaboratory using SSH or TurboVNC.
remocolab is a Python module to allow remote access to Google Colaboratory using SSH or TurboVNC. It also install VirtualGL so that you can run OpenGL programs on a Google Colaboratory machine and see the screen on VNC client. It secures TurboVNC connection using SSH port forwarding.
~~ngrok currently doesn't work!~~ ngrok works now
You cannot directory login to the SSH server running on a colab instace. remocolab uses third party service to access it from your PC. You can choose ngrok or Argo Tunnel. You don't need to buy paid plan. Which service works faster can depend on where/when you are. - ngrok - require that you sign up for an account. - You don't need to install specific software on client machine. - You need to copy and paste authtoken to colab everytime you run remocolab. - Argo Tunnel - You don't need to create account. Cloudflare provide free version - You need to copy cloudflared on your client PC. - You cannot specify argo tunnel server's region. They says the connection uses Argo Smart Routing technology to find the most performant path.
If you use ngrok: - ngrok Tunnel Authtoken - You need to sign up for ngrok to get it
If you use Argo Tunnel: - Download cloudflared on your client PC and untar/unzip it.
console ssh-keygen -t ecdsa -b 521
remocolab.setupSSHD(public_key = "ecdsa-sha2-nistp521 AAA...")
tunnel = "ngrok"if you use ngrok.
python3 !pip install git+https://github.com/demotomohiro/remocolab.git import remocolab remocolab.setupSSHD()
python3 !pip install git+https://github.com/demotomohiro/remocolab.git import remocolab remocolab.setupVNC()
remocolab.setupVNC(), you can save ngrok token to a notebook. Then, you might forget that your notebook contains it and share the notebook.
remocolab.setupVNC()in the code like
remocolab.setupSSHD(ngrok_region = "jp").
remocolab.setupSSHD()takes about 2 minutes
remocolab.setupVNC()takes about 5 minutes
Copy & paste that ssh command to your terminal on your local machine and login to the server.
If you use TurboVNC:
Run TurboVNC viewer on your local machine, set server address to
Then, password will be asked. Copy & paste the VNC password displayed in
remocolab.setupVNC()'s output to your TurboVNC viewer.
When you got error and want to rerun
remocolab.setupSSHD(), you need to do
factory reset runtimebefore rerun the command. As you can run only 1 ngrok process with free ngrok account, running
remocolab.setupVNC/setupSSHDwill fail if there is another instace that already ran remocolab. In that case, terminate another instance from
Put the command to run the OpenGL application after
vglrun. For example,
vglrun firefoxruns firefox and you can watch web sites using WebGL with hardware acceleration.
remocolab can allow colab user reading/writing files on Google Drive. If you just mount drive on Google Colaboratory, only root can access it.
Click the folder icon on left side of Google Colaboratory and click mount Drive icon. If you got new code cell that contains python code "from google.colab import ...", create a new notebook, copy your code to it and mount drive same way. On new notebook, you can mount drive without getting such code cell. - You can still mount google drive by clicking the given code cell, but it requres getting authorization code and copy&pasting it everytime you run your notebook. - If you mount google drive on new notebook, it automatically mount when your notebook connect to the instance.
mount_gdrive_toargument with directory name to
remocolab.setupVNC(). For example:
python remocolab.setupSSHD(mount_gdrive_to = "drive")Then, you can access the content of your drive in
/home/colab/drive. You can also mount specific directory on your drive under colab user's home directory. For example:
python remocolab.setupSSHD(mount_gdrive_to = "drive", mount_gdrive_from = "My Drive/somedir")
ngrok_regionSpecify ngrok region like "us", "eu", "ap". List of region. This argument is ignored if you specified
tunnel = "argotunnel".
check_gpu_availableWhen it is
True, it checks whether GPU is available and show warning in case GPU is not available.
tunnelSpecify which service you use to access ssh server on colab. It must be "ngrok" or "argotunnel". default value is "argotunnel".
mount_gdrive_toSpecify a directory under colab user's home directory which is used to mount Google Drive. If it was not specified, Google Drive is not mount under colab user's home directory. Specifying it without mounting Google Drive on Google Colaboratory is error.
mount_gdrive_fromSpecify a path of existing directory on your Google Drive which is mounted on the directory specified by
mount_gdrive_to. This argument is ignored when
mount_gdrive_towas not specified.
public_keySpecify ssh public key if you want to use public key authentication. ## How to setup public key authentication for root login If you want to login as root, use following code:
python3 !mkdir /root/.ssh with open("/root/.ssh/authorized_keys", 'w') as f: f.write("my public key") !chmod 700 /root/.ssh !chmod 600 /root/.ssh/authorized_keysAnd replace user name colab in ssh command to root.
~~remocolab in kaggle branch works on Kaggle.~~ 1. Create a new Notebook with Python language. 2. Set settings to: - Internet on - Docker to Latest Available - GPU on if you use TurboVNC 3. Add a code cell and copy & paste one of following codes to the cell
python3 !pip install git+https://github.com/demotomohiro/[email protected] import remocolab remocolab.setupSSHD()
SSH and TurboVNC:
python3 !pip install git+https://github.com/demotomohiro/[email protected] import remocolab remocolab.setupVNC()