Skip to content

Instantly share code, notes, and snippets.

@ellisbrown
Created September 6, 2022 23:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ellisbrown/3f7eea6d4d859100bcad601c9135f8c1 to your computer and use it in GitHub Desktop.
Save ellisbrown/3f7eea6d4d859100bcad601c9135f8c1 to your computer and use it in GitHub Desktop.
VNC Server setup

VNC Server

NOTE: I randomly chose display number :99 for this demo. If you are working on a shared machine, you should choose a random number so that you do not conflict with other users.

Installation

  1. Install TigerVNC:
    sudo apt install tigervnc-standalone-server -y 
  2. Start the VNC server:
    # create a virtual display (#99) for ai2thor to use
    vncserver -localhost no -httpPort 5999 :99
    This will require you to set a password. The final output should be something like:
    New 'MACHINE:99 (USER)' desktop at :99 on machine MACHINE
    
    Once the display is created, you AI2thor should have somthing to connect to. 3. Set the DISPLAY environment variable to the corresponding screen number :99. The conda environment should have this set by default. If not, run the following command to update the conda environment variable:
    conda activate <env_name>
    conda env config vars set DISPLAY=:99
    • In any python code, you may also need to set the DISPLAY environment variable to the corresponding display number to get it to run correctly (e.g. os.environ['DISPLAY'] = ':99').
  3. Fixing issues with the virtual screen
    • See the status by running
      vncserver -list
      The following is an example of the output with a stale screen:
      TigerVNC server sessions:
      
      X DISPLAY #	PROCESS ID
      :99		30309 (stale)
      
    • Kill the screen using the following command:
      vncserver -kill :99
      Now repeat step 2!
VNC help:
  • You can use vncserver -kill :99 to kill the server if you want.
  • viewing the display:
    • there are various VNC viewers. I use the built in one on Mac. Instructions below:

Mac VNC Viewer:

You need to forward the port of the VNC server (5999 above) to your local machine over SSH, and have a stable connection open. Then you can open the viewer with:

open vnc://localhost:5999

Headless VNC Server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment