RStudio Server¶
RStudio Server provides a web-based integrated development environment (IDE) for R, allowing you to run interactive R sessions on Hyperion compute nodes while accessing them through your local web browser. This approach combines the convenience of RStudio's familiar interface with the computational power of the cluster.
Overview¶
When you launch RStudio Server on Hyperion, a dedicated R session runs on a compute node with access to:
- Cluster resources — High-memory nodes, multiple CPU cores, and fast parallel storage
- Your files — Direct access to home, scratch, and project directories
- Installed software — All R packages and modules available on the cluster
- Persistent sessions — Your R environment persists for the duration of your job
The connection workflow is:
┌──────────────┐ SSH Tunnel ┌──────────────┐ Internal ┌──────────────┐
│ Your Machine │ ──────────────────────│ Login Node │ ─────────────────▶ │ Compute Node │
│ Browser │ (encrypted) │ hyperion │ │ RStudio │
└──────────────┘ └──────────────┘ └──────────────┘
This ensures secure, encrypted access to your session from any location.
Instructions¶
Step 1: Request Compute Resources¶
RStudio Server must run on a compute node, not on the login node. You can request resources either interactively or through a batch job.
Option A: Interactive Session¶
For exploratory work or shorter sessions, request an interactive allocation:
srun -n1 -N1 -c4 --mem=16G --time=04:00:00 -p regular --pty bash
Adjust the resources according to your needs:
| Parameter | Description | Example Values |
|---|---|---|
-c | CPU cores | 1, 4, 8, 16 |
--mem | Memory | 4G, 16G, 64G, 128G |
--time | Wall time | 01:00:00, 08:00:00, 24:00:00 |
-p | Partition | regular, long |
Choosing Resources
Start with modest resources (4 cores, 16G memory) and increase if needed. Requesting excessive resources may result in longer queue times.
Option B: Batch Job¶
For longer sessions or automated workflows, create a batch script named rstudio.slurm:
#!/bin/bash
#SBATCH --job-name=rstudio
#SBATCH --output=rstudio-%j.out
#SBATCH --error=rstudio-%j.err
#SBATCH --time=08:00:00
#SBATCH --cpus-per-task=4
#SBATCH --mem=32G
#SBATCH --partition=regular
module load RStudio-Server
start_rstudio_server.sh
Submit the job:
sbatch rstudio.slurm
Monitor your job status:
squeue -u $USER
Once the job is running, retrieve the connection information from the output file:
cat rstudio-<JOBID>.out
Step 2: Start RStudio Server¶
Once your allocation is active, execute the startup script:
start_rstudio_server.sh
The script will display connection information:
- Interactive session: The information appears directly on screen
- Batch job: The information is written to the output file (
rstudio-<JOBID>.out)
================================================================================
RSTUDIO SERVER SESSION INFO
================================================================================
Job ID: 1234567
Node: hyperion-107.sw.ehu.es
Port: 8945
Username: username
Password: xK9mPq2wL5nR
--------------------------------------------------------------------------------
CONNECTION INSTRUCTIONS
--------------------------------------------------------------------------------
1. Open a terminal on your local machine and run:
ssh -N -L 9999:localhost:8945 -J username@hyperion.sw.ehu.es hyperion-107
2. Open your web browser and navigate to:
http://localhost:9999
3. Log in with the credentials above.
4. To terminate the session, cancel the Slurm job:
scancel 1234567
================================================================================
Save Your Credentials
Note down the password displayed on screen. This password is randomly generated for each session and is required to log in to RStudio.
Step 3: Create SSH Tunnel¶
The SSH tunnel securely forwards traffic from your local machine to the compute node. Open a new terminal window on your local machine and run the SSH command provided in the connection information.
The tunnel command follows this pattern:
ssh -N -L <local-port>:localhost:<remote-port> -J <username>@hyperion.sw.ehu.es <node>
Where:
| Component | Description | Example |
|---|---|---|
<local-port> | Port on your machine (you choose this) | 9999, 8888, 5555 |
<remote-port> | Port where RStudio runs (from connection info) | 8945 |
<username> | Your cluster username | jsmith |
<node> | Compute node (from connection info) | hyperion-107 |
Choosing a Local Port
The local port (e.g., 9999) can be any available port on your machine between 1024 and 65535. If you get an "address already in use" error, simply choose a different port. The URL in your browser must match this port (e.g., http://localhost:9999).
Keep the Tunnel Open
The terminal running the SSH tunnel will appear to hang with no output. This is normal behavior. The tunnel remains active until you press Ctrl+C or close the terminal. Keep this terminal open while using RStudio.
Linux and macOS¶
Open a terminal and run:
ssh -N -L 9999:localhost:8945 -J username@hyperion.sw.ehu.es hyperion-107
Replace username, 8945, and hyperion-107 with your actual values from the connection information. You may also change 9999 to any available port on your local machine.
Windows¶
Using PowerShell or Command Prompt (Windows 10/11)¶
Windows 10 and later include a built-in SSH client. Open PowerShell or Command Prompt and run:
ssh -N -L 9999:localhost:8945 -J username@hyperion.sw.ehu.es hyperion-107
Adjust the values as described above.
Step 4: Access RStudio¶
- Open your web browser (Chrome, Firefox, Safari, or Edge)
- Navigate to
http://localhost:<local-port>using the local port from your tunnel command (e.g.,http://localhost:9999) - Enter your cluster username and the password from the connection information
- The RStudio interface should now appear
Browser Recommendations
Chrome and Firefox provide the best experience with RStudio Server. If you encounter display issues, try a different browser.
Working with RStudio on the Cluster¶
File Access¶
RStudio has direct access to all your cluster files:
| Location | Path | Description |
|---|---|---|
| Home | /home/username or /dipc/username | Personal files, R libraries |
| Scratch | /scratch/username | Temporary large files |
| Projects | Varies by group | Shared project data |
Navigate using the Files pane in RStudio or R commands:
# Check current directory
getwd()
# Change to scratch
setwd("/scratch/username")
# List files
list.files()
Using R Modules¶
Before starting RStudio Server, you can load additional R-related modules that will be available in your session:
module load R/4.3.0
module load RStudio-Server
start_rstudio_server.sh
Parallel Computing¶
Your R session has access to the CPU cores you requested:
# Check available cores
parallel::detectCores()
# Example with mclapply
library(parallel)
results <- mclapply(1:100, my_function, mc.cores = 4)
Other parallelization options include foreach/doParallel and future/future.apply.
Memory Management¶
R can only use the memory requested in your Slurm allocation. Monitor usage with gc() and check object sizes with object.size(). If you encounter "cannot allocate vector" errors, submit a new job with higher --mem.
Efficient Data I/O¶
For large datasets, consider using data.table::fread() or vroom::vroom() instead of base R functions. For saving R objects, saveRDS()/readRDS() or the qs package provide fast binary storage.
Ending Your Session¶
Saving Your Work¶
Before ending your session:
- Save all open files: File → Save All
- Save your R workspace if needed:
save.image("/path/to/workspace.RData") - Note any file paths you'll need for future sessions
Terminating the Session¶
You can end your RStudio session in several ways:
From your local machine:
scancel <JOBID>
From the RStudio interface:
- Close the browser tab and let the job expire naturally, or
- Use the terminal within RStudio to run
scancel $SLURM_JOB_ID
Important: Simply closing the browser does not terminate the Slurm job. The job continues running until it reaches its time limit or is explicitly cancelled.
Troubleshooting¶
Connection Refused¶
If you see "Connection refused" when accessing your localhost URL:
- Verify the SSH tunnel is running (check the terminal where you started it)
- Confirm the port numbers are correct:
- The local port in your tunnel must match the port in your browser URL
- The remote port in your tunnel must match the port from connection info
- Ensure the RStudio Server is still running:
squeue -u $USER
Connection Reset¶
If the connection drops immediately:
- Use the ProxyJump (
-J) syntax as shown in the examples - Verify you're connecting to the correct compute node
Authentication Failed¶
If RStudio rejects your credentials:
- Use your cluster username (not email)
- Use the password from the connection info (not your cluster password)
- Passwords are case-sensitive
RStudio Interface Not Loading¶
If the browser shows a blank page or loading indicator:
- Clear browser cache and reload
- Try a different browser
- Check the Slurm error file:
cat rstudio-<JOBID>.err
Session Expired¶
If your session becomes unresponsive:
- Your Slurm job may have reached its time limit
- Check job status:
squeue -u $USER - Submit a new job with longer
--timeif needed
Best Practices¶
- Request appropriate resources: Don't over-request; it increases queue time
- Use scratch for large files: Keep your home directory clean
- Monitor your jobs: Check
squeueperiodically - Clean up: Cancel jobs you no longer need with
scancel - Use batch jobs for long sessions: They're more reliable than interactive sessions
Getting Help¶
If you encounter issues not covered in this documentation:
- Check the Slurm output and error files for your job
- Review the RStudio Server logs:
~/.local/share/rstudio/log/ - Contact support with your job ID and a description of the problem