Skip to content

ucla-oarc-hpc/H2-RStudio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

RStudio on Hoffman2

Easily run RStudio on Hoffman2 (H2) compute nodes.

Available RStudio Containers

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.

RStudio Workshop

For more information on using RStudio on Hoffman2, visit the H2HH RStudio Workshop.

Running RStudio: Step-by-Step Guide

Follow these steps to run RStudio using an RStudio container on Hoffman2:

  1. Request an interactive job:

    RStudio and Apptainer can only run on a compute node, not on a login node.

qrsh -l h_data=10G
  1. Create temporary directories:

    RStudio needs these directories to run correctly. Create them in your $SCRATCH directory.

mkdir -pv $SCRATCH/rstudiotmp/{var/lib,var/run,tmp}
  1. Load Apptainer module:
module load apptainer
  1. 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.

  1. 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 
  1. 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.

Running RStudio: Automated TUI (experimental)

The h2rstudio TUI automates the entire process: SSH key setup, job submission, tunnel creation, and browser launch.

Download and Setup

Mac:

wget https://github.com/ucla-oarc-hpc/H2-RStudio/releases/latest/download/h2rstudio
chmod +x h2rstudio
./h2rstudio

Windows:

wget https://github.com/ucla-oarc-hpc/H2-RStudio/releases/latest/download/h2rstudio.exe
h2rstudio.exe

Installing from Source

You may also install from source.

cd h2rstudio-go
go build ./cmd/h2rstudio

On 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.

Running R in Batch Mode

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.

Troubleshooting Common Issues

If a new RStudio session doesn't start correctly (e.g., due to an improper exit), try the following:

  1. 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.

  1. Clear RStudio config files:
rm -rf $HOME/.config/rstudio
rm -rf $HOME/.local/share/rstudio
  1. 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.

About

Using RStudio on Hoffman2

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors