linuxipythongoogle-colaboratoryx11-forwarding

x11 forwarding through Google Colab


I was hoping to get x11 forwarding to work on Google Colab. I am using a Windows 10 machine and the Google Colab OS information can be found at the bottom of the post. Here's what I did to test it out:

  1. Installed Xming and ran it.
  2. Made a new IPython notebook in Google Colab and installed x11 apps successfully using

    !sudo apt-get install x11-apps
    
  3. Set my display to be my IP address using

    !export DISPLAY=<my-ip-address>
    
  4. Run !xeyes. I get an error message saying Error: Can't open display:

I'm not sure if this is a problem of using the correct DISPLAY setting, running x11 forwarding through Google Colab or both!Can anyone help me out? Thank you!

The relevant parts of the output of when I run !cat /etc/os-release on my Google Colab notebook.

NAME="Ubuntu"
VERSION="18.04.3 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
VERSION_ID="18.04"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

Solution

  • tl;dr

    1. Open 6000/tcp port on your router and firewall
    2. Install VcXsrv
    3. Run "XLaunch" with "Disable access control"
    4. Run "!apt-get install x11-apps && export DISPLAY=YOUR_IP_ADDRESS:0.0 && eyes" on Colab

    enter image description here

    Check

    1. Google Colab does not keep environment variables across code cells. So you should set DISPLAY variable each them.

    Google Colab does not keep environment variables across code cells

    1. Xming may disallow remote connection as a default setting. At least, VcXsrv do that. Try to disable access control. This is an insecure option.

    enter image description here

    1. Router and firewall must open 6000+n/tcp port. The n is display number counting from 0. (e.g. HOSTNAME:0.0 → n=0) Open Port Check Tool - Test Port Forwarding on Your Router enter image description here