All this tutorial assumes you are inside IDIBELL network or using IDIBELL’s VPN.

Configure SSH access

In the Terminal Console (in Rstudio):

ssh-keygen.exe -t rsa

You can leave the default file names and location. You can also leave blank the passphrase.

After generating the keys, we are going to configure the connection details. This is not necessary but it makes it easy to connect on a regular basis.

Create a text file names “config” inside C:\Users\YourDNI\.ssh. If the .ssh directory does not exist, create it. Inside the config file, add the following information:

Host idibell
  HostName 172.19.1.20
  User mcosta

Finally, we will authorize our keys in the cluster server so we don’t need the password every connection. As we have configured the “idibell” connection, we don’t need to specify the IP every time. It will ask your password for one time.

ssh-copy-id idibell

Now we can connect without password by just typing:

ssh idibell

Conda Enviroment Set Up

This is done in the server after connecting through ssh idibell command

In order to install R and R packages in a controlled and allowed environment, we will use conda and its r-packages. It is already installed in the cluster server.

First, we create the new conda enviroment called r_env and then we activate it:

conda create -n r_env
conda activate r_env

Then we install R:

conda install r r-essentials --channel conda-forge

To install R packages, we have to do it through conda:

conda install r-<package> --channel conda-forge

For example:

conda install r-tidyverse --channel conda-forge

You can find here the available packages in conda-forge channel.

Rstudio

The workflow is the following: you use your local Rstudio IDE (the one in your computer), where you have your scripts. However, instead of sending commands to local Console, you send it to the Terminal, which is executing R in the cluster server.

First we assign a key shortcut to “Send to Terminal”. “Go to Terminal” is Alt+Maj+M.

We go to Tools > Modify Keyboard Shortcuts > Send Selection to Terminal and assign a shortcut. In my case Ctrl+Alt+Enter.

If you are not connected yet, type in the Terminal:

ssh idibell

Connect to a computation node using slurm:

srun --mem=16G --cpus-per-task=8 -t 12:00:00 --pty bash

In this case, I have asked for 16 GB of RAM memory and 8 CPUs, and a total time limit of 12 hours. You can adapt this numbers to your needs.

Activate the R environment:

conda init bash #This is only required the first time
conda activate r_env

You will notice a “(r_env)” at the start of the line.

Finally, we start R by typing:

R

Remember you can use your custom shortcut to send lines to the Terminal.