Analysis3 not working with R

Hi all,

I’m trying to run an interactive session on the ARE with Rstudio. I’m assuming that the conda/analysis3 also manages R packages as well as python, and so i was wanting to use it.

However, it looks like using the analysis3 module when starting an Rstudio instance causes an instant crash to my session. The error logs are as follows:

workdir is /home/581/pjb581/ondemand/data/sys/dashboard/batch_connect/sys/rstudio/ncigadi/output/67ecccbe-16a9-4a9d-8834-b653f70c2339/rstudio-work-dir
Script starting...
Waiting for RStudio server to open port 31612...
TIMING - Starting wait at: Wed Sep 17 22:28:51 AEST 2025
TIMING - Starting main script at: Wed Sep 17 22:28:51 AEST 2025
Loading conda/analysis3-25.08
  Loading requirement: singularity
/g/data/xp65/public/apps/med_conda_scripts/analysis3-25.08.d/bin/R
/g/data/xp65/public/apps/med_conda_scripts/analysis3-25.08.d/bin/R
TIMING - Starting rstudio at: Wed Sep 17 22:28:52 AEST 2025
+ export PATH=/g/data/xp65/public/apps/nci_scripts:/g/data/xp65/public/apps/med_conda_scripts/analysis3-25.08.d/bin:/opt/pbs/default/bin:/opt/nci/bin:/opt/bin:/opt/Modules/v4.3.0/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/local/pbs/bin:/opt/singularity/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/lib/rstudio-server/bin
+ PATH=/g/data/xp65/public/apps/nci_scripts:/g/data/xp65/public/apps/med_conda_scripts/analysis3-25.08.d/bin:/opt/pbs/default/bin:/opt/nci/bin:/opt/bin:/opt/Modules/v4.3.0/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/local/pbs/bin:/opt/singularity/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/lib/rstudio-server/bin
+ echo /g/data/xp65/public/apps/nci_scripts:/g/data/xp65/public/apps/med_conda_scripts/analysis3-25.08.d/bin:/opt/pbs/default/bin:/opt/nci/bin:/opt/bin:/opt/Modules/v4.3.0/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/local/pbs/bin:/opt/singularity/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/lib/rstudio-server/bin
/g/data/xp65/public/apps/nci_scripts:/g/data/xp65/public/apps/med_conda_scripts/analysis3-25.08.d/bin:/opt/pbs/default/bin:/opt/nci/bin:/opt/bin:/opt/Modules/v4.3.0/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/local/pbs/bin:/opt/singularity/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/lib/rstudio-server/bin
+ ssh-agent -- rserver --www-port 31612 --auth-none=0 --auth-pam-helper-path=pam-helper --auth-stay-signed-in-days=30 --auth-timeout-minutes=0 --auth-encrypt-password 0 --rsession-path=/etc/rstudio/rsession.sh --server-user pjb581
+ die 'ERROR: RStudio exited with non-zero code (1)'
+ MSG='ERROR: RStudio exited with non-zero code (1)'
+ '\[' '!' -z 'ERROR: RStudio exited with non-zero code (1)' '\]'
+ echo '<div class="error-msg">ERROR: RStudio exited with non-zero code (1)</div>'
+ kill -9 219752
++ date
+ echo 'TIMING - Finished RStudio at: Wed Sep 17 22:28:52 AEST 2025'
TIMING - Finished RStudio at: Wed Sep 17 22:28:52 AEST 2025
-/bin/bash: line 1: 219713 Killed                  /local/spool/pbs/mom_priv/jobs/149907369.gadi-pbs.SC

======================================================================================
                  Resource Usage on 2025-09-17 22:28:55:
   Job Id:             149907369.gadi-pbs
   Project:            es60
   Exit Status:        137 (Linux Signal 9 SIGKILL Kill, unblockable)
   Service Units:      0.04
   NCPUs Requested:    28                     NCPUs Used: 28              
                                           CPU Time Used: 00:00:01        
   Memory Requested:   252.0GB               Memory Used: 118.87MB        
   Walltime requested: 12:00:00            Walltime Used: 00:00:04        
   JobFS requested:    400.0MB                JobFS used: 0B              
======================================================================================

At this stage I would appreciate any feedback on how to:
(1) run Rstudio with analysis3
(2) if this isn’t possible, how to create my own R package environment

Thanks for your help,
Pearse

Hi Pearse

R and some packages are installed in analysis3 but it’s true that I have not tried to run them in an RStudio session. Let me have a look.

1 Like

Hi Pearse,

If you want to start an R session, there is no need to call conda/analysis3. In fact, you can start a session without editing any of the advanced settings.

Here is a link to NCI documentation about R, which includes instructions on how to install libraries: R... - NCI Help - Opus - NCI Confluence

The documentation includes instructions with an older version of R (v 4.3) and there was a discussion in a different forum (21st century weather group) that mentioned that these instructions did not apply to R 4.5. This is the link to the thread in case you have access to it: https://21centuryweather.discourse.group/t/r-coding-on-gadi/1414

I haven’t tried to install any packages in the latest version of R, but I’m tagging @paocorrales because she’s like a master of R and may be able to help.

3 Likes

Hello!

I agree with @lidefi87, you don’t need analysis3 to use R. I’d actually recommend to never use R through conda, the packages are installed in a different way and I’ve seen very weird errors because of that.

The link to the NCI documentation is a good starting point, in summary you install the packages you want in your personal library. There are a few extra details to take into account:

  • Some packages need system libraries to compile, you will need to load these with module load.
  • The packages are, by default installed in your home directory and it can add up a lot. There are ways to move that to /g/data to avoid storage issues
  • If you are interested in creating a reproducible environment for a specific project you can use renv. Here is a tutorial 01: Managing R dependencies with renv | An R reproducibility toolkit for the practical researcher but I’m happy to help!
3 Likes

Thank you all for your rapid help. I will have a go at creating my custom R environment with the links that have been shared. I’ll let you know on here if I run into any problems.

Thanks!

pearse

1 Like

I actually agree with paocorrales. We have some R packages installed in analysis3 but that is to support some ESMValTool recipes. I don’t think it will be the best approach for interactive analysis. I would recommend creating your own R environment.

Hi Denisse,

I don’t have access to that link in the 21st century weather forum. Could you possibly copy it or screenshot it an share it with me by any chance? Or perhaps post it here?

Thanks,
pearse

Here is the important bit from that thread on Cumulus:

It seems that R 4.5.0 was compiled to be more efficient using intel and the specific node architectures of the different types of nodes in Gadi. gcc doesn’t have the same capabilities and if you want to compile any package with it, you need to set specific flags.

By default (and following the NCI documentation) R should use intel to compile packages. If you need to use gcc, you will need to add a Makevars file in ~/.R/Makevars with the necesary flags. NCI suggest to comment/change the name of the file after installing the package.

For R 4.5.0, the content of the Makevars file should be:

CXX=g++
CXX11=g++
CXX14=g++
CXX17=g++
CC=gcc
CFLAGS= -march=x86-64
CXXFLAGS= -march=x86-64
SHLIB_OPENMP_CFLAGS= -fopenmp

x86-64 it may not be the most efficient option but hopefully NCI will update the documentation soon with the recommended option.

I’d suggest to install the packages with only the modules you need. I always start with:

module purge
module load R/4.5.0
module load intel-compiler-llvm/2025.0.4 #compilers used for this R version
module load intel-mkl/2025.0.1           #compilers used for this R version

Trying to use the same compiler NCI used for the specific R version (/apps/R/4.5.0/README.nci). And then I start adding the modules I need for specific packages.

2 Likes

Very helpful. Thank you Pao!

Also, do you have any pointers for making the R session plot/output occur within the R Markdown script? It was doing it for me before, but now for some reason it won’t plot or output summary statistics within the script. Are there any tricks to enabling/removing this sort of functionality?

Pearse

I have this on my RStudio:

I’d check those options first.

1 Like

I have not tried it, but given what you’ve said above @paocorrales about building dependencies for R it sounds like spack might be a worth a look.

It supports a lot of R packages it seems:

Here is a (short) write-up on using it in a container in an HPC environment:

1 Like