Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This is an example of what can be achieved on Nimbus Research Cloud. The detailed configuration for various VM flavours and OS configurations might differ. Nimbus users are responsible for managing their VMs and installing tools. We believe that this step-by-step example might be helpful to run RStudio interactively.


Panel
titleThis page:

Table of Contents

On Nimbus, you can run RStudio interactively. It requires three main steps:

  1. Run Rstudio's server with an assigned port from an RStudio container
  2. Create SSH port forwarding to the rserver from your local computer
  3. Open Rstudio through a localhost port browser

Run the RStudio server command


On your Nimbus instance: 

Pull the RStudio container using the command below.

Note

The following command assumes that you have Singularity installed. All Pawsey images have Singularity pre-installed. If you need to install Singularity, see the documentation here. This step assumes that you already have the /data directory from attaching your storage volume. In this step you are creating a sub-directory called sif_lib, which is for storing your Singularity containers.


Code Block
>sudo mkdir /data/sif_lib
>sudo singularity pull --dir /data/sif_lib/ docker://rocker/rstudio:3.6.1


Note

You may have to set ownership of the /data directory to the user so that you can bind-mount it to the container in the next step:

>sudo chown ubuntu:ubuntu /data/

Run the rserver command as follows. When running this command, you are also assigning the port 8787 for forwarding to later.

IMPORTANT: Replace abc with a more secure password.

Code Block
>PASSWORD='abc' singularity exec -B /data:/home /data/sif_lib/rstudio_3.6.1.sif rserver --www-port 8787 --www-address 0.0.0.0 --auth-none=0 --auth-pam-helper-path=pam-helper
  • singularity exec invokes the container to run the rserver command.
  • -B is a flag used to for bind-mounting /data, which is a directory on your instance. /home is the container's directory /data is bind-mounted to. Do not replace /home.
  • You can replace /data with a directory of your choice, as long as it has user ownership.


You should not see any output at this point, except a "running" command, i.e. the port is forwarded and running.

Warning

If this command results in an error message "failed to find loop device", try running the command until you do not get an error message. This is due to a bug on the older versions (older than v3.5) of Singularity. You can circumvent this error by installing v3.5 or using the "Ubuntu 18.04 - 2020-04 - Pawsey" image.


Create SSH port forwarding


In a terminal on your local computer:

Run the following command. Replace your-keypair.pem with the keypair you created for your instance, and the external-IP-address with your instance's external IP address, which you can find on your Nimbus dashboard.

Code Block
>ssh -i ~/.ssh/your-keypair.pem -N -f -L 8787:localhost:8787 ubuntu@external-IP-address


Note

If you require to kill any 8787 ports to run it again, use the following command:

>lsof -ti:8787 | xargs kill -9

You will not see output until you have done the next step, Open RStudio.

Open RStudio


  1. Open up a browser window (IMPORTANT: Firefox does not work. Use Chrome or Safari.)
  2. Go to http:/localhost:8787
  3. Enter the username, which is your image operating system, e.g. ubuntu.
  4. Enter the password, which in this example is abc.
  5. Once you have RStudio opened, you will need to create a library directory where your R packages will be installed to:

    • Click on the "New Folder" icon in the bottom right box inside RStudio, and give it the name "library", which is now the folder you will use in your new library path.
    • Then, in the RStudio console, run the following command to default the library path to your newly created "library" folder:

      Code Block
      .libPaths(c('/home/rstudio/library'))


      Warning

      You have to run this command with every new RStudio server session, as the container is non-writable and will not save this setting when you exit it.


  6. Run your R commands as you normally would. All output is saved to the directory you have chosen to bind-mount in the RStudio server command.



Panel
titleAdvanced Topics & Troubleshooting:

Children Display
pageAdvanced Topics


...