Skip to main content

Using RStudio

Using RStudio

As another example, if you wish to use RStudio instead of a terminal then you may access a private instance via your web browser by taking the following steps:

  1. Create a batch script (e.g. run.sh) containing the following:
#!/bin/bash
#SBATCH --time=0-01:00:00 # Request 1 hour of wall time
#SBATCH --ntasks=1 # Only open 1 instance of the server
#SBATCH --cpus-per-task=4 # Use 4 cores
#SBATCH --mem=8G # Use 8G of RAM
##SBATCH --gres=gpu:1 # Use 1 GPU - the double hash means this is not active
#SBATCH --output=server.output.%j # Send output to file named 'server.output.{jobid}'

module purge
module load RStudio-Server

# Use a pre-built script to launch RStudio
/modules/containers/rstudio/start_rstudio_4.3.2.sh

# The log-in credentials can be found in the file 'server.output.{jobid}'
# after the job launches, e.g. 'cat server.output.232', where 232 is your job id.

You may, of course, modify the resources as needed for your particular tasks/needs within RStudio.

  1. Submit the job to the scheudler:
$ sbatch run.sh
Submitted batch job 232
  1. View the contents of the output file - modify the job id to match the output you receive from the above command:
$ cat server.output.232
1. SSH tunnel from your workstation using the following command:

ssh -L 8787:c01:45779 -N NetID@arseven.stat.tamu.edu

and point your web browser to http://localhost:8787

2. log in to RStudio Server using the following credentials:

user: NetID
password: bWzagjS3uCBpuT1goa9E

When done using RStudio Server, terminate the job by:

1. Exit the RStudio Session ("power" button in the top right corner of the RStudio window)
2. Issue the following command on the login node:

scancel -f 232
  1. Follow the instructions in the output. More specifically:

  2. The first step tells you to start an SSH tunnel from your workstation. To do this, open another terminal window, and copy-paste the SSH command (e.g. ssh -L 8787:c01:45779 -N NetID@arseven.stat.tamu.edu) into the other terminal. Note that after running this, the command will appear to "hang" or "do nothing" as it will not return until you use Ctrl+C or close that terminal.

  3. Open a web browser and go to http://localhost:8787

  4. When prompted enter the user and password that are given to you in the output.

  5. When finished with RStudio:

  6. Exit RStudio using the "power" button in the top right corner

  7. Close your we browser

  8. Return to the terminal with the SSH tunnel running and either press Ctrl+C or close the terminal.

  9. On the cluster enter scancel -f 232, replacing 232 with your job id.

Note that like all jobs on the cluster, your RStudio session is time-limited, and by default not warn you that the time has expired. Ensure that you schedule sufficient time for your testing, and please remember that this is a shared resource.