RStudio Server on HPC

Run RStudio Server as a Singularity container on a compute node

One-time Setup

Before first use, you need to enable reverse SSH connection from compute nodes to the login node.

ssh <username>@<hpc_ip>
srun --pty bash
ssh <hpc_ip>

You only need to do this successfully once. You may exit the terminal after completing this step.

Usage

Submit the RStudio Server job. The output file will contain instructions for subsequent steps.

  1. Download the script to your home directory:
curl -O https://wanggroup.org/scripts/rstudio_cumc_cloud.sh
  1. Modify the script as needed:

    • Adjust memory and wall time requirements
    • Add bash configurations before the RStudio launch command (e.g., custom paths from your ~/.bashrc)
    • Add module load Singularity/4.2.1 before the singularity command
  2. Submit the job. Choose the option that matches your setup:

    With your own R installation (preferred approach for Gao Wang’s lab):

   sbatch rstudio_cumc_cloud.sh -i  -s /path/to/rstudio-no-r.sif -r ~/.pixi/envs/r-base/bin

You can also omit -r if R is in your PATH — in that case the script auto-detects R.

Please refer to CU_Neurology_HPC_Info_2026.md (requires CUMC VPN or on-campus connection) for path to this SIF file on our HPC.

With container’s bundled R (e.g., rocker-based containers):

   sbatch rstudio_cumc_cloud.sh -i  -s /path/to/rstudio-server.sif

Connect

After the job starts, check the job output file for connection info:

cat rstudio_<JOBID>.out

Replace <JOBID> with your actual job ID. You’ll see instruction like:

========================================
RStudio Server - Job 12345678
========================================
On your LOCAL machine, run:
  ssh -N -L 8787:/tmp/username/rstudio_12345678/rstudio.sock username@hpc_ip

Then open: http://127.0.0.1:8787
To stop:   scancel 12345678
========================================

Session cache: /home/username/rstudio-status/share
For a fresh start, remove cache: rm -rf /home/username/rstudio-status/share

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!  IMPORTANT: USE INCOGNITO/PRIVATE BROWSER WINDOW   !!!
!!!  Otherwise you may get 'user not found' errors     !!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Replace <JOBID> with your actual job ID, then open http://127.0.0.1:8787.

OpenSSL Mismatch

The script checks OpenSSL compatibility between your R and the container. If mismatched, it errors out with instructions. If you see an OpenSSL mismatch error, rebuild the no-R container with a matching RStudio version:

Your R’s OpenSSL Use RSTUDIO_VERSION
3.x 2026.01.0-392
1.x 2023.12.1-402

To do so, edit rstudio.def, change RSTUDIO_VERSION, then:

singularity build --fakeroot rstudio-no-r.sif rstudio.def

If you cannot run --fakeroot under your HPC account you can do this on a local desktop or laptop and upload the resulting sif file to HPC; or ask our IT admin to do this for you.

(Of course you could rebuild your R environment to match the container, but most likely you don’t want to.)

Notes

  • Cost: Terminate when done: scancel <JOBID>
  • Port: Use -p <port> to change local port from default 8787, if that port is not available because you want to run multiple Rstudio server sessions.