slurm
How do config R in Slurm
[TOC]
Conda environment
- Create environment Create R environment using 4.4.1 version.
1
conda create -n R4.4-syf R=4.4.1 -y
- Check current environments
1
conda env list
- Activate & Deactivate environment
1
2
3
4
5# activate
conda activate env_name # change to env_name created before
conda activate R4.4-syf # eg.
# deactivate
conda deactivate R4.4-syf - Delete env
1
conda remove -n env_name --all -y
Install jags
- Download and Tar
Download package from here1
2
3
4
5
6
7mkdir ./JAGS-4.3.2
tar -zxf ./jags_4.3.2.orig.tar.gz
cd ./JAGS-4.3.2
./configure
make
make check
make install - Conda install rjags
After tar JAGS, conda install rjags in command.1
conda install -c conda forge r-rjags
- Install package in R
Activate R environment using command in shell:R1
2
3install.packages("R2jags")
library(rjags)
library(R2jags)
Running R script using Shell in Slurm
The test shell script: submit_test.sh
R script: test_hpc_parallel.R
To run the R script using conda environment, the shell script:
1 | module purge |
Following error will occur:
1 | CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'. |
To solve this, source conda.sh before activate, and use the full path for the R scipt.
The revised shell script:
1 | module purge |
Others
conda install freezing
When install r-pkg,solving environmentfreezing often occurs, to solve this, replacecondainstall withmamba.conda channels operations
1
2conda config --show channels # show current channels
conda config --remove channels defaults # remove defaults channelTo add new channels:
1
2
3vim ./condarc
# add in condarc via vim
conda config --show channels # check channels added status