# Remote Desktops with TurboVNC

To make full use of the graphical computing capabilities of the servers
available to the SOAR team, [TurboVNC with VirtualGL](https://en.wikipedia.org/wiki/VirtualGL)
has been made available. This enables low latency 3D accelerated virtual remote
desktop access on Linux host servers even across high latency links by performing
JPEG realtime JPEG compression of a virtualized hardware accelerated display.
This can then be viewed and interacted with using the lightweight TurboVNC client.

Currently, only the Dev Server (autodrive-dev) is available to use with hardware
accelerated rendering. On the Dev Server, the Nvidia GTX 1080 Ti is currently
assigned to perform all hardware acceleration tasks, leaving the TITAN Xp
completely available to perform deep learning tasks.

## Client Installation

TurboVNC clients are available for Linux, Mac, and Windows operating systems
and can be downloaded from: <https://sourceforge.net/projects/turbovnc/>

## Usage Instructions

To connect to the remote desktop, VPN access should first be configured and
established. Next, the VNC server can be started via SSH:

```bash
ssh <netid>@autodrive-dev.egr.msu.edu '/opt/TurboVNC/bin/vncserver -fg'
```

You will be prompted to enter your _autodrive_ password (which must be initially
set using the NAS at autodrive-nas.egr.msu.edu using a one-time-password
generated by a system administrator).

Be sure to include the `-fg` flag to run in the foreground to ensure the server
isn't killed when the SSH process completes (the default behavior of the `vncserver`
command it to return and run in the bacground).

Once successfully authenticating, the server should respond with something
similar to:

```bash
Desktop 'TurboVNC: autodrive-dev:1 (<netid>)' started on display autodrive-dev:1

Starting applications specified in /home/<netid>/.vnc/xstartup.turbovnc
(Enabling VirtualGL)
Log file is /home/<netid>/.vnc/autodrive-dev:1.log
```

Notice the line `Desktop 'TurboVNC: autodrive-dev:1 (<netid>)' started on
display autodrive-dev:1`; this tells you which display number the virutal
desktop is started on. In this case, the virtual display number is `1`.

The session is now ready to be connected to with the TurboVNC client. Open the
TurboVNC client either through your local machine's applications menu, or on
your local machine's terminal by entering into a terminal (Linux/macOS only):

```bash
/opt/TurboVNC/bin/vncviewer
```

Once the client opens, a window will appear. Enter the fully qualified domain
name of the Dev Server (autodrive-dev.egr.msu.edu) followed by a colon and
the display number as shown in the following picture.

![Screen_Shot_2021-01-07_at_9.07.31_PM](~/static/uploads/843e7590568495c840607a579d5a618c/Screen_Shot_2021-01-07_at_9.07.31_PM.png)

Then click "connect". If successful, you will be presented with an authentication
window similar to the one below:

![Screen_Shot_2021-01-07_at_9.22.26_PM](~/static/uploads/b440fcbdfebd6b6046b267bae0a111f5/Screen_Shot_2021-01-07_at_9.22.26_PM.png)

You must authenticate using your autodrive username and password to access the
session. Press 'enter' to send credentials. If the correct credentials are
entered, you should be presented with a desktop environment similar to the one below:

![Screen_Shot_2021-01-07_at_9.41.46_PM](~/static/uploads/0502a2bb52e4efa841fd0f46e658327a/Screen_Shot_2021-01-07_at_9.41.46_PM.png)

Finally, please remember to LOG OFF when you have completed your session,
otherwise your session will continue indefinitely, consuming resources on the server.

![Screen_Shot_2021-01-07_at_9.26.46_PM](~/static/uploads/f53b2e5bac181f3baf6e78b8ff169aa5/Screen_Shot_2021-01-07_at_9.26.46_PM.png)

## Tuning Performance

To adjust performance settings, the "connection options..." menu may be accessed
from the menu bar and will display a menu similar to the one below:

![Screen_Shot_2021-01-07_at_9.31.45_PM](~/static/uploads/762bb96c0e6ff984a0b153529aef77cf/Screen_Shot_2021-01-07_at_9.31.45_PM.png)

Typically "Tight + Medium-Quality JPEG" is a good balance of performance and
picture quality and provides usable latency when viewing interactive 3D content
while on most high speed internet connections (>12 Mbps, <100ms ping time).
Higher latency connections will inevitably incur a performance penalty in
the ability to interact in realtime.

In general, resizing the window to be smaller will also help increase performance,
especially if a larger/high-res display is used on the local machine.
