Easily run RStudio on Hoffman2 (H2) compute nodes.
Find available RStudio containers on Hoffman2 with the following command:
module load apptainer
ls $H2_CONTAINER_LOC/h2-rstudio*sif
To create your own RStudio container or use a different version, visit the UCLA OARC HPC Containers repository.
For more information on using RStudio on Hoffman2, visit the H2HH RStudio Workshop.
Follow these steps to run RStudio using an RStudio container on Hoffman2:
-
Request an interactive job:
RStudio and Apptainer can only run on a compute node, not on a login node.
qrsh -l h_data=10G
-
Create temporary directories:
RStudio needs these directories to run correctly. Create them in your
$SCRATCHdirectory.
mkdir -pv $SCRATCH/rstudiotmp/{var/lib,var/run,tmp}
- Load Apptainer module:
module load apptainer
- Start RStudio process:
Do not kill this process until you are finished with RStudio.
export RSTUDIO_VERSION=4.5.0
apptainer run \
-B $SCRATCH/rstudiotmp/var/lib:/var/lib/rstudio-server \
-B $SCRATCH/rstudiotmp/var/run:/var/run/rstudio-server \
-B $SCRATCH/rstudiotmp/tmp:/tmp \
$H2_CONTAINER_LOC/h2-rstudio_${RSTUDIO_VERSION}.sif
You can replace export RSTUDIO_VERSION=4.5.0 with any RStudio version available on Hoffman2.
This will display information and an ssh -L ... command to run in a separate terminal.
- Connect to the compute node's port:
Open a new terminal and run the provided ssh -L ... command.
ssh -L 8787:nXXX:8787 username@login1.hoffman2.idre.ucla.edu # Or whatever command was displayed earlier
- Access RStudio in your web browser:
Enter the following URL in your web browser:
http://localhost:8787 # Or whatever port number that was displayed
You will be asked for your Username and Password. The Username is your Hoffman2 username and the Password was randomly created and displayed in the previous terminal screen.
When finished, exit RStudio and press [Ctrl-C] in the terminal running the RStudio container to exit the job.
The h2rstudio TUI automates the entire process: SSH key setup, job submission, tunnel creation, and browser launch.
Mac:
wget https://github.com/ucla-oarc-hpc/H2-RStudio/releases/latest/download/h2rstudio
chmod +x h2rstudio
./h2rstudioWindows:
wget https://github.com/ucla-oarc-hpc/H2-RStudio/releases/latest/download/h2rstudio.exe
h2rstudio.exeYou may also install from source.
cd h2rstudio-go
go build ./cmd/h2rstudioOn first run, the TUI will guide you through installing an app-only SSH key. Subsequently, you can launch RStudio sessions with your requested resources.
If you encounter any issues with the TUI, please submit a Support Ticket.
If you want to use the R version in the container for a batch job, use the rstudio_batch.job script. This example SGE job script submits an R job using the R version inside the RStudio container and uses the installed libraries. This is helpful if you have installed packages with RStudio and want to run an R batch job with the same version of R and R packages.
If a new RStudio session doesn't start correctly (e.g., due to an improper exit), try the following:
- Remove RStudio temporary directories:
rm -rf $SCRATCH/rstudiotmp
mkdir -pv $SCRATCH/rstudiotmp/var/lib
mkdir -pv $SCRATCH/rstudiotmp/var/run
mkdir -pv $SCRATCH/rstudiotmp/tmp
Make sure you create the temporary directories again before restarting RStudio.
- Clear RStudio config files:
rm -rf $HOME/.config/rstudio
rm -rf $HOME/.local/share/rstudio
-
Check your HOME user quota:
If you are at your storage quota limit in your HOME directory, RStudio may not start correctly. You can check your quota by using the following command:
du --max-depth=1 -h $HOME
This can help you find which directories use most of your storage quota.
By following these guidelines and solutions, you should be able to easily run RStudio on Hoffman2 compute nodes and troubleshoot any common issues that may arise.