UA Research Computing

HPC Examples

Running RStudio Using a Singularity Image

In some circumstances, you may want to run RStudio using your own Singularity image. For example, this allows access to different versions of R not provided when using our OOD application.

To do this, log into HPC using an Open OnDemand Desktop session and open a terminal. A Desktop session is the easiest solution to access RStudio since it eliminates the need for port forwarding.

In the terminal, make an RStudio directory where all of the necessary files will be stored. In this example, we’ll be working in our home directory and will pull an RStudio image from Dockerhub to use as a test. If you’re interested, you can find different RStudio images under rocker in Dockerhub.

[netid@gpu22 ~]$ mkdir $HOME/RStudio
[netid@gpu22 ~]$ cd $HOME/RStudio
[netid@gpu22 RStudio]$ singularity pull ./geospatial.sif docker://rocker/geospatial.sif

Next, create the necessary directories RStudio will use to generate temporary files. You will also generate a secure cookie key.

[netid@gpu22 RStudio]$ TMPDIR=$HOME/RStudio/rstudio-tmp
[netid@gpu22 RStudio]$ mkdir -p $TMPDIR/tmp/rstudio-server
[netid@gpu22 RStudio]$ uuidgen > $TMPDIR/tmp/rstudio-server/secure-cookie-key
[netid@gpu22 RStudio]$ chmod 600 $TMPDIR/tmp/rstudio-server/secure-cookie-key
[netid@gpu22 RStudio]$ mkdir -p $TMPDIR/var/{lib,run}

Next, create a file in your RStudio directory called and make it an executable:

[netid@gpu22 RStudio]$ touch
[netid@gpu22 RStudio]$ chmod u+x

Open the file in your favorite editor and enter the content below. Modify the variables under USER OPTIONS to match your account if necessary. You can change PASSWORD to any password you’d like to use. Once you’ve entered the contents, save and exit:

# --- USER OPTIONS --- #
PASSWORD=$PASSWORD singularity exec -B $TMPDIR/var/lib:/var/lib/rstudio-server -B $TMPDIR/var/run:/var/run/rstudio-server  -B $TMPDIR/tmp:/tmp $SIF rserver --auth-none=0 --auth-pam-helper-path=pam-helper --server-user=$NETID --www-address=

Now, in your desktop session’s terminal, execute the script using:

[netid@gpu22 RStudio]$ ./


Next, open a Firefox window and enter localhost:8787 for the URL. In your browser, you will be prompted to log into your RStudio server. Enter your NetID under Username. Under Password, enter the password you defined in the script


This will open your RStudio session: