Load and run R
Practice using the documentation of your HPC cluster
Load an R module
Start the R interpreter
Run an R script
Download and extract the exercise files
(optional) Find the different R modules
(optional) See the list of installed R packages
Teaching goals are:
Learners have practiced using the documentation of their HPC clusters
Learners have loaded the module to be able to run R
Learners have run the R interpreter
Learners have run an R script from the command-line
Learners have downloaded and extracted the exercise files
(optional) Learners have found the different R modules
(optional) Learners have seen the list of installed R packages
Prior:
What is ‘HPC’ in ‘HPC cluster’?
What is ‘cluster’ in ‘HPC cluster’?
What is a software module?
What is a script?
What are features of using an HPC cluster?
What problem would arise if users can install their own software?
Introduction
You want to run R on an HPC cluster. For this, you’ll need to read the documentation of your HPC cluster.
In this session, we will use the documentation of your HPC cluster to start R.
Warning
Only do lightweight things!
We are still on the login node, which is shared with many other users. This means, that if we do heavy calculations, all the other users are affected.
How to do heavy calculations will be shown in this course later.
Exercises
Prefer this session as video?
HPC cluster |
Login method |
Location |
---|---|---|
COSMOS |
Local ThinLinc client |
|
Dardel |
Local ThinLinc client |
|
Kebnekaise |
Local ThinLinc client |
|
Rackham |
Local ThinLinc client |
|
Tetralith |
Local ThinLinc client |
HPC cluster name |
Main breakout room |
COSMOS |
Room 1 |
Dardel |
Room 2 |
Kebnekaise |
Room 3 |
Rackham |
Room 4 |
Tetralith |
Room 5 |
Exercise 1: start the R interpreter
Find the documentation of your HPC cluster
Answer
Within the documentation of your HPC cluster, search for the documentation about R
Answer
HPC cluster |
Page name and location |
---|---|
COSMOS |
|
Dardel |
|
Kebnekaise |
|
Rackham |
|
Tetralith |
From the terminal, load the module(s) for R, of the recommend version as shown below
HPC center |
R version |
---|---|
COSMOS |
4.2.1 |
Dardel |
4.1.1 |
Kebnekaise |
4.1.2 |
Rackham |
4.1.1 |
Tetralith |
4.2.2 |
Answer
HPC cluster |
How to load the module(s) for R |
---|---|
COSMOS |
|
Dardel |
|
Kebnekaise |
|
Rackham |
|
Tetralith |
|
From the terminal, start the R interpreter
Answer
HPC cluster |
How to start the R interpreter |
---|---|
COSMOS |
|
Dardel |
|
Kebnekaise |
|
Rackham |
|
Tetralith |
|
From the R interpreter, run the R code
message("Hello")
to verify if this makes the R interpreter show the text ‘Hello’From the R interpreter, run the R code
quit()
to quit the R interpreter and go back to the terminal
Exercise 2: run an R script
To run an R script, we’ll download one, after which we’ll run it:
From the terminal, run
wget https://raw.githubusercontent.com/UPPMAX/R-python-julia-HPC/main/exercises/r/hello.R
From the terminal, run
Rscript hello.R
Exercise 3: download and extract the tarball with exercises
See here how to download and extract the tarball with exercises.
Exercise X1: find and use installed R packages
From the R interpreter, check which packages are installed, using
installed.packages()
Answer
HPC cluster |
Answe |
---|---|
COSMOS |
|
Dardel |
|
Kebnekaise |
|
Rackham |
|
Tetralith |
|
From the R interpreter, load the
parallel
package, usinglibrary(parallel)
Answer
HPC cluster |
Answe |
---|---|
COSMOS |
|
Dardel |
|
Kebnekaise |
|
Rackham |
|
Tetralith |
|
Exercise X2: search for other R versions
Use the module system to find which versions of R are provided by your cluster’s module system.
Answer
HPC cluster |
How to search for the R modules |
---|---|
COSMOS |
|
Dardel |
|
Kebnekaise |
|
Rackham |
|
Tetralith |
|