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.
- Install TigerVNC:
sudo apt install tigervnc-standalone-server -y
- Start the VNC server:
This will require you to set a password. The final output should be something like:
# create a virtual display (#99) for ai2thor to use vncserver -localhost no -httpPort 5999 :99
Once the display is created, you AI2thor should have somthing to connect to. 3. Set theNew 'MACHINE:99 (USER)' desktop at :99 on machine MACHINE
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'
).
- In any python code, you may also need to set the
- Fixing issues with the virtual screen
- See the status by running
The following is an example of the output with a stale screen:
vncserver -list
TigerVNC server sessions: X DISPLAY # PROCESS ID :99 30309 (stale)
- Kill the screen using the following command:
Now repeat step 2!
vncserver -kill :99
- See the status by running
- 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:
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
- install dummy XServer
sudo apt install xterm xserver-xorg-video-dummy
- https://www.sproutworkshop.com/2021/04/how-to-create-a-virtual-headless-tigervnc-server-on-ubuntu-20-04/