Due to the complicated setup and average experience of remote desktops, if it’s not a strong necessity for you, it is recommended that you make corresponding adjustments to your code (for example, replace OpenCV’s
imshow with imsave to save images and then view them).About VNC
VNC (Virtual Network Computing) is a graphical desktop sharing protocol that uses the remote framebuffer protocol (RFB) to remotely control another computer. It transmits keyboard and mouse events from one computer to another and forwards graphical screen updates over the network in the opposite direction. For general GUI program execution needs, we can actually use VNC to conveniently implement this without installing a complete desktop environment. Below is an introduction on how to use the TurboVNC tool to run a GUI program within an instance and display it on your local computer:1
Step 1
Install VNC and some necessary graphics libraries:
1.1 Install basic dependency packages
bash
2
Step 2
When starting the server, the rfbport=6006 port was manually set. Next, an SSH tunnel will be used to proxy the 6006 port from the instance to your local machine.
After completing the above steps, use a VNC client to connect with the address 
127.0.0.1:6006.
Use the TurboVNC client on your local computer to connect to the address obtained above. If everything goes well, after entering the password, you will see the graphical interface after a successful VNC connection, as well as the GUI program running on the instance. Additionally, download links for the TurboVNC client for different systems are provided here (you can also download from the official TurboVNC website).- For Ubuntu: TurboVNC 2.2.5 for Ubuntu
- For MacOS: TurboVNC 2.2.5 for MacOS
- For Windows: TurboVNC 2.2.5 for Windows

3
Step 3
Add the environment variable in the terminal: If the image is displayed in the local VNC client, it proves that the installation and startup process are correct.
export DISPLAY=:1, and then run your command (make sure to execute it in the same terminal).
You can use the following Python code for a simple verification:python