R on Rocky 9¶
With the major operating system upgrade from Centos 7 to Rocky 9, we want to ensure that using R, RStudio, and Open OnDemand (OOD) is as seamless as possible. This post will include new tips for a better experience, as well as a reiteration of the important or frequently forgotten old tips.
Starting fresh ☀️¶
When encountering any issues with your OOD RStudio, the first place to start is
with a completely new session. If possible, ensure that you close out of any and
all currently running sessions properly using Quit Session...
or the power
button. Then delete the RStudio session from your My Interactive Sessions
tab.
Start a short running session, check to ensure your Global Options are set
accordingly.
If changes are needed, apply then quit the session properly again.
Finally, request a session that you intend to work in. There should be no old
variables loaded (except nslots
).
Avoid idle interactive sessions¶
If you have come to a point in your analysis where you no longer need to interact with your session (for example, a long running function), it is best to consider a job script. As OOD is intended for consistent interaction, issues may arise in your session when it's not monitored.
Whilst not recommended, if you have returned to an idle interactive session, it's best to follow the steps above to ensure reproducible behaviour.
It should also be noted that running multiple RStudio OOD sessions at one time may lead to inconsistent behaviour and should be avoided if possible.
Check in on your home directory 🏠¶
Be sure that you are not getting close to your home storage quota of 100GB. RStudio will not open or you will see a 502 error if it doesn't have adequate space. To do this, please see the documentation.
Blank slate¶
If you have done all of the above and are still struggling to get a working
session, usually seen as a stuck grey screen upon entering RStudio, you may
need to move your ~/.local/share/rstudio
folder aside by running the
following in your
terminal:
mv ~/.local/share/rstudio ~/.local/share/rstudio-backup
This will be recreated when you start a new session.
Untangle installation¶
Incompatibilities and errors can occur if any packages fail during an installation. Running into continuous errors during an install can be a sign of this. Please clear out your existing library using the following command:
rm -rf ~/R/x86_64-pc-linux-gnu-library/4.4
In this instance, we are removing the R 4.4 library. When future versions are released, be sure to change this to the relevant version.
Speeding things up¶
While upgrading package libraries can seem daunting, the new Rocky 9 setup has been optimised to make this as simple as possible. Additional modules are no longer needed for almost all cases.
To speed up library creation, remember that installing packages can be be parallelised. 8 cores will significantly reduce the installation time. Just remember to exit your installation session and create a new session to work in, one that has the relevant number of cores for your analyses.
Watch these packages ⚠️¶
Many package creators try to parallelise processes for the user. In most cases this is a welcomed optimisation. However, there are a few that cause issues for HPC users.
readr
contains the function read_tsv()
, which incorrectly sets the number of
cores available (via detectCores()
). It can be avoided by including the
parameter readr_threads = nslots
within the function. However, many packages
import this package and function as-is which will cause issues for the user and
the cluster.
And as always, avoid
detectCores()
within your own scripts at all costs.
Title image mixed: Josh Urbain and Hayden Young on GitHub & The R Foundation on r-project.org