Skip to content

Remote Desktop Environments

You can run a full desktop on a compute node (including GPU nodes) by launching an interactive job with either desktop environment: MATE or Xfce. This lets you use terminal, file explorer, or other GUI tools (for example, an image viewer) directly on the compute nodes. This may reduce the need to transfer files to your local machine for viewing or analysis.

Custom Containers

It is possible to install custom software in a remote desktop environment, using Apptainer. Follow the steps below for example container definition files with VNC and desktop packages installed. At the moment, it is possible to use only Xfce and MATE desktop environments.

Start with a template definition file

You will want to start with a template definition file. The easiest way would be to clone the git repository, and choose either xfce.def or mate.def as your template.

git clone https://gitlab.uzh.ch/s3it/examples/desktop_containers
cd desktop_containers

Each .def template file has a section that is ready for the steps to install custom software.

########
# Add your customisation steps here

#
########

We will edit xfce.def here but the procedure is the same for mate.def.

Note

Without root permission, you cannot always build a container directly on ScienceCluster. If that should be the case, build the container image (.sif) file on your computer or on a ScienceCloud VM (for example, using one of the supported Singularity/Apptainer images). After transferring the .sif file to ScienceCluster, you can run it using Apptainer.

Understanding the placeholders

The first placeholder is in the %labels section. You can optionally set additional labels that describe the container. Typical labels are Maintainer, Version, and Description.

The next placeholder is in the %environment section. Here, you can add environment variables that you would like to be set when you run the container. If you need to change PATH, make sure to append to it, e.g. export PATH=/opt/bin:$PATH.

In the %post section, there are two placeholders. The first one can be used for installing additional packages and software as well as for most other changes. We will install spyder package and build GSL from source. You would not normally need to build GSL from source because the GSL package can be installed from Ubuntu apt repository but it provides a good demonstration.

Adding the installation of custom software

To accomplish these two tasks, we add the following code to the first placeholder.

########
# Add your customisation steps here

# Install spyder package and prerequisites to compile GSL
apt-get -qq install -y --no-install-recommends spyder build-essential git

# Build and install GSL
mkdir /opt/install
git clone https://github.com/ampl/gsl /opt/install/gsl
cd /opt/install/gsl
./configure --prefix=/opt
make
make install

#
########

The source code for GSL is no longer needed and can be removed. This is what the second placeholder in the %post section is for.

########
# (Optional) add your clean up steps here

rm -rf /opt/install

#
########

Since we installed GSL into a custom location, it may be good to add its location to PATH and set LIBRARY_PATH.

########
# (Optional) add your environment variables here

export PATH=/opt/bin:$PATH
export LIBRARY_PATH=/opt/lib

#
########

Building and testing the custom container

Once the definition file is ready, we can build the container.

apptainer build xfce.sif xfce.def

Let's check if both applications can be found in the container. This could be done automatically in the test section of the definition file. However, since we are not automating this process, a manual check should be sufficient.

apptainer exec xfce.sif bash -c "which spyder && which gsl-config"

The command should output:

/usr/bin/spyder
/opt/bin/gsl-config

The container is ready and can be transferred to the cluster. For example, you can place it into /home/$USER/containers directory.

Running the custom container in ScienceApps

Once the container is in place, you can go to ScienceApps and select Xfce from the list of the Desktop applications. In the Custom container field, enter the absolute path to the container on the ScienceCluster file system. If you've used the ~/containers/ folder as described above, then the absolute path will be /home/$USER/containers/xfce.sif.

After you connect to the desktop with a ScienceApps Xfce session, verify that both spyder and GSL are available from inside the Desktop Environment.