How do I use VNC on Tigressdata?

VNC is a graphical desktop sharing system that allows users to connect to remote computers. It is advantageous because it eliminates the need to send 3D data over the network via an X-Windows environment. The instructions here describe how to connect to a remote desktop on tigressdata. You can then take advantage of the local CPU and GPU capabilities of the tigressdata machine. It is highly recommended to use this for applications that do 3D rendering.

 

TurboVNC Installation & Use

1. Install TurboVNC

On your local machine (your computer), download and install the TurboVNC client from here: http://sourceforge.net/projects/turbovnc.

The most recent version should be fine, but we have tested with 1.2.

2. Start a VNC Session

Use your ssh shell window (such as the Terminal application on MacOS or Linux, or something like PuTTY or Mobaxterm on Windows) to ssh into tigressdata and start a vnc session.

  • Connect to tigressdata
    • ssh <your_netid>@tigressdata.princeton.edu
  • Load the turbovnc module to enable vnc commands
    • module load turbovnc
  • Start a vnc session
    • vncserver
      • NOTE: The first time you start vncserver you will be prompted to create a password to access your vnc desktops. This can be anything you like. Should you choose to change it in the future simply delete the file ~/.vnc/passwd, and the next time you start a vnc session you will be prompted to recreate a password.
        • You may also be prompted to setup a different, view-only password. This is for instances where others can view your desktop, but keystrokes are disabled. If you choose to set up a view-only password, use a password that you would feel comfortable sharing with others.
      • You should get an output that looks like this:

Desktop 'TurboVNC: tigressdata.princeton.edu:1 (NetID)' started on display tigressdata.princeton.edu:1

Creating default startup script /home/NetID/.vnc/xstartup.turbovnc
Starting applications specified in /home/NetID/.vnc/xstartup.turbovnc

Log file is /home/NetID/.vnc/tigressdata.princeton.edu:1.log

  • Note the session number. In the above example it is :1.
    • You can always check what vnc session(s) you have open with the "vncserver -list" command which gives an output like:

$ vncserver -list

TurboVNC server sessions:

X DISPLAY # PROCESS ID
:1 18966

3. Connect to VNC.

Use the TurboVNC viewer application (downloaded in step 1) to connect to the graphical desktop.

  • i. First open an ssh tunnel.
    • Open a new ssh shell window, and from your local machine (i.e. not in tigressdata) set up a a new ssh tunnel. This is necessary because TurboVNC is not encrypted. Below is an example for the above session (:1) when run on a Linux/Mac, but make sure to use the proper command for your operating system. Also remember to use your own session number and to enter your own netID before "@tigressdata".
      • Example for the above session (:1) when using Linux/Mac:
        • ssh -A -L 5901:localhost:5901 netID@tigressdata.princeton.edu
      • Choose the appropriate command for your operating system (modify content within the <>'s, where "n" refers to the session number from earlier):
        • Linux/Mac: ssh -A -L <5900+n>:localhost:<5900+n> <user>@tigressdata.princeton.edu
        • Windows - 32-bit (from a command prompt, all on one line): "C:\Program Files (x86)\TurboVNC\putty" -L <5900+n>:localhost:<5900+n> <netID>@tigressdata.princeton.edu
        • Windows - 64-bit (from a command prompt, all on one line): "C:\Program Files\TurboVNC\putty" -L <5900+n>:localhost:<5900+n> <netID>@tigressdata.princeton.edu
    • You may see a message or dialog box similar to this: "The server's host key is not cached in the registry". If you do, type or click "yes".
    • Enter the password associated with your netID.
  • ii. Now connect to the graphical desktop. 
    • Open the TurboVNC Viewer application that you downloaded in the first step, and in the VNC server box type "localhost:<n>" (for example: "localhost:1").
      Dialog box from TurboVNC application, where user has entered localhost:2
      • If you receive an error message saying 'JRELoadError,' you need to install the Java software OpenJDK.
        • On a Mac machine:
          • Download OpenJDK to your computer by following the instructions in the 'Uninstall Oracle Java and Install OpenJDK Instructions' section of this article
          • Use a text editor like vim or emacs to add the following two lines to your ~/.bash_profile:
            export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre 
            launchctl setenv JAVA_HOME $JAVA_HOME
          • Then activate the changes by running: source ~/.bash_profile
        • On a Linux machine:
          • Install OpenJDK, currently jdk-13.0.1.  It downloads as a tar.gz file so it can be installed anywhere.
          • Use a text editor like vim or emacs to add the following line to the file ~/.bashrc:
            export PATH=/your/path/to/jdk-13.0.1/bin:$PATH
            Then activate the changes by running: source ~/.bashrc
    • Click connect.
    • Enter the password you set up when you created your vncserver session above.
    • You should now be able to see your tigressdata desktop.

Screenshot of the graphical desktop produced by TurboVNC.

 

Closing TurboVNC and VNC sessions

  • One advantage of this system is that you can take a break from your work, but your vncsession will remain open and you can reconnect at any time.
    • In other words, if you close the ssh tunnel and/or the TurboVNC viewer application (both of which you opened in step 3), your vncsession (what you opened in step 2) will remain intact. Just reconnect.
    • To reconnect at a later time and pick up right where you left off, repeat the procedure for connecting to a remote VNC session (step 3).
  • When you are finished with a VNC session entirely, you should end it.
    • To end a vnc session:
      • ssh to tigressdata (see above)
      • If you haven't already, load the turbovnc module
        • module load turbovnc
      • Check the number of your vnc session with vncserver -list and note the display # of the session you want to end
      • Do "vncserver -kill :<n>" where n is the number (with a colon).
        • Example:
          • vncserver -kill :1

 

VirtualGL

  • To take full advantage of the local graphics hardware of tigressdata we use VirtualGL. Note this will only work within a VNC session. The instructions here are for a terminal open on your VNC desktop.
  • Check to make sure you have the virtualgl module loaded, if not do
    • module load virtualgl
  • Start a program as you normally would but precede the command with vglrun. Some examples:
    • vglrun visit (after doing "module load visit")
    • vglrun paraview (after doing "module load paraview")
    • vglrun /usr/licensed/matlab/bin/matlab

 

Simplify the Process to Connect to TurboVNC

For users who connect frequently to TurboVNC, the process described above can be simplified with the use of shell functions. Consider adding the following to simplify your log-in:

1. Add these functions to your .bashrc file on tigressdata:

turbostart() { module load turbovnc && if [[ $(vncserver -list | wc -l) == 4 ]]; then vncserver; else echo -e "\n***SESSION ALREADY RUNNING***" && vncserver -list; fi }
turbostopall() { module load turbovnc && x in `vncserver -list`; do if [[ $x =~ ^: ]]; then vncserver -kill $x; fi; done }

2. Add this shell function to the startup script on your local machine (e.g., .bash_profile on macOS or .bashrc on Linux) and be sure to replace NetID with your netid:

turbossh() { ssh -A -L $(( 5900 + $1 )):localhost:$(( 5900 + $1 )) NetID@tigressdata.princeton.edu; }

3. Once you have entered these three functions and sourced your scripts - for example, source(.bashrc), source(.bash_profile), etc. - a typical session can be started as follows:

i. Log into tigressdata and start a vnc session.

ssh NetID@tigressdata.princeton.edu
turbostart

ii. In a new shell, from your local machine open an ssh tunnel (if the session number is 42, for example):

turbossh 42

iii. Launch the TurboVNC Viewer application and in the VNC server box enter 'localhost:42'.

4. To end the session on tigressdata:

turbostopall