index 日本語

Internet of Tomohiro

If you found my articles interesting or useful, please donate using following links:


How to run OpenGL desktop programs on Google Colaboratory

2022/9/15: Using a remote desktop or SSH is now disallowed from Colab runtimes

Unigine Valley Running on Google Colaboratory
  1. Requirements
  2. Procedure
  3. Run OpenGL programs
    1. Run Shadertoy
    2. Run Unigine Valley
    3. Use Blender
    4. Use Godot
  4. How it works
  5. Display smooth animation
  6. Change remote desktop size

Requirements

You need to use ngrok or Argo Tunnel to access desktop environment on Google Colaboratory.

Procedure

More details of this procedure:

https://github.com/demotomohiro/remocolab/blob/master/README.md

If you have questions:

https://github.com/demotomohiro/remocolab/wiki/Frequently-Asked-Questions

  1. Sign up for ngrok if you use it
  2. If you use Argo Tunnel, download cloudflared to your PC and install it or put the executable file in one of directories in PATH environment variable
  3. Change runtime type if you want to use OpenGL

  1. Copy following code to a cell in Colaboratory
  2. Click run bottom in top left
  3. Copy ngrok authtoken if you use ngrok
  4. Select ngrok region
  5. Wait for TurboVNC running
  6. Login to Google Colaboratory using SSH
  7. Run TurboVNC Viewer

After connecting VNC server, you will see the screen like this.

You can check the availability of NVIDIA OpenGL implementation with following command.

$ vglrun /opt/VirtualGL/bin/glxinfo | grep NVIDIA

If everything fine, you will see following output.

OpenGL vendor string: NVIDIA Corporation
OpenGL core profile version string: 4.6.0 NVIDIA 418.67
OpenGL core profile shading language version string: 4.60 NVIDIA
OpenGL version string: 4.6.0 NVIDIA 418.67
OpenGL shading language version string: 4.60 NVIDIA

Run OpenGL programs

Following steps are supposed to be run on remote desktop. TurboVNC Viewer can copy & paste between your PC and remote PC. OpengL programs need to be run with vglrun command or it uses software GLX/OpenGL implementation included in The TurboVNC and rendering can be slow.

If you want to run a program from SSH and display it on the VNC screen, add DISPLAY=:1 to your command like this:

$ DISPLAY=:1 vglrun firefox &

Run Shadertoy

Open terminal and execute following commands.

$ su
# apt install firefox
# exit
$ vglrun firefox

Then, open Shadertoy on the firefox.

Run Unigine Valley

Download Unigine Valley from Unigine Valley . Then, extract the file and run it like following command.

$ chmod +x Unigine_Valley-1.0.run
$ ./Unigine_Valley-1.0.run
$ cd Unigine_Valley-1.0
$ vglrun ./valley

Use Blender

Download the file for Linux 64bit from official Blender site. Then, extract the file and run it like following command.

$ tar xf blender-2.79b-linux-glibc219-x86_64.tar.bz2
$ cd blender-2.79b-linux-glibc219-x86_64
$ vglrun ./blender

Use Godot

Download the file for Linux 64bit from official Godot site. The, extract the file and run it like following command.

$ unzip Godot_v3.1-stable_x11.64.zip
$ vglrun ./Godot_v3.1-stable_x11.64

How it works

remocolab download and install OpenSSH, TurboVNC , libjpeg-turbo, VirtualGL and Xfce . It run desktop on Google Colaboratory 's virtual machine and make it accessible from your PC using TurboVNC. TurboVNC send desktop screen on the server to the client PC running TurboVNC Viewer , and receive mouse and keyboard input from the client PC. TurboVNC compress desktop screen image using libjpeg-turbo before sending it. These communications are encrypted by using SSH port forwarding. remocolab configures TurboVNC so that connecting to it without using SSH is forbidden. VirtualGL allow OpenGL programs can use Hardware accelerator using a GPU on server like they are executed on normal desktop.

Display smooth animation

Open TurboVNC Viewer Options and change Encoding method to Tight + Medium-Quality JPEG or Tight + Low-Quality JPEG(WAN) . Some noise will appear but looks smoother.

Change remote desktop size

Open TurboVNC Viewer Options, click Connection tab and set Remote desktop size.

Frequently-Asked-Questions


by Tomohiro

index