BwUniCluster2.0/Software/R/Glmnet: Difference between revisions
< BwUniCluster2.0 | Software | R
Jump to navigation
Jump to search
Tag: Manual revert |
|||
(13 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
<span style="color:red"><b>Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)!</b></span> |
|||
⚫ | |||
= General information = |
|||
Consider starting an interactive job for compiling. Copy and paste the following to your shell. |
|||
<code>glmnet</code> is an <code>R</code> package that fits generalized linear and similar models via penalized maximum likelihood, particularly, lasso and elastic-net. |
|||
⚫ | |||
== Preparations == |
|||
Installing <code>glmnet</code> involves compiling source code. Therefore, ensure that the following flags are set in <code>$HOME/.R/Makevars</code>: |
|||
<pre> |
<pre> |
||
⚫ | |||
⚫ | |||
⚫ | |||
CXX14=g++ |
|||
# Prepare .R directory (if it does not already exists) |
|||
CXX17=g++ |
|||
CXX14FLAGS += -std=c++14 |
|||
CXX17FLAGS += -std=c++17 |
|||
CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option |
|||
</pre> |
|||
If necessary, the appropriate compiler flags can be set by running the following lines of code: |
|||
<pre> |
|||
mkdir -p ~/.R |
mkdir -p ~/.R |
||
echo "CXX14=g++" > ~/.R/Makevars |
|||
echo "CXX17=g++" >> ~/.R/Makevars |
|||
echo "CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option" >> ~/.R/Makevars |
|||
echo "CXX14FLAGS += -std=c++14" >> ~/.R/Makevars |
|||
echo "CXX17FLAGS += -std=c++17" >> ~/.R/Makevars |
|||
</pre> |
|||
Since installing <code>glmnet</code> involves compiling, we start an <b>interactive session</b> on one of the compute nodes: |
|||
# Write the following environment variables to Makevars |
|||
<pre> |
|||
⚫ | |||
salloc -n 1 -t 30 -p dev_single |
|||
echo "CXX14FLAGS=-O3 -fPIC -std=c++14 -axCORE-AVX512,CORE-AVX2,AVX -xSSE4.2 -fp-model strict -qopenmp" >> ~/.R/Makevars |
|||
</pre> |
|||
== Install <code>glmnet</code> == |
|||
<pre> |
|||
⚫ | |||
⚫ | |||
# Install the glmnet package from within R session |
# Install the glmnet package from within R session |
||
R -q |
R -q |
||
⚫ | |||
⚫ | |||
</pre> |
|||
== Test the installation == |
|||
As a quick test of the installation of <code>glmnet</code> the following lines of code can be run: |
|||
<pre> |
|||
# Run a quick test |
# Run a quick test |
||
> library(glmnet) |
> library(glmnet) |
Latest revision as of 10:48, 30 October 2024
Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)!
General information
glmnet
is an R
package that fits generalized linear and similar models via penalized maximum likelihood, particularly, lasso and elastic-net.
Installation instructions
Preparations
Installing glmnet
involves compiling source code. Therefore, ensure that the following flags are set in $HOME/.R/Makevars
:
cat ~/.R/Makevars CXX14=g++ CXX17=g++ CXX14FLAGS += -std=c++14 CXX17FLAGS += -std=c++17 CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option
If necessary, the appropriate compiler flags can be set by running the following lines of code:
mkdir -p ~/.R echo "CXX14=g++" > ~/.R/Makevars echo "CXX17=g++" >> ~/.R/Makevars echo "CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option" >> ~/.R/Makevars echo "CXX14FLAGS += -std=c++14" >> ~/.R/Makevars echo "CXX17FLAGS += -std=c++17" >> ~/.R/Makevars
Since installing glmnet
involves compiling, we start an interactive session on one of the compute nodes:
salloc -n 1 -t 30 -p dev_single
Install glmnet
# Load the R software module: module load math/R/4.4.1-mkl-2022.2.1-gnu-13.3 # Install the glmnet package from within R session R -q R> install.packages("glmnet")
Test the installation
As a quick test of the installation of glmnet
the following lines of code can be run:
# Run a quick test > library(glmnet) > data(QuickStartExample) > x <- QuickStartExample$x > y <- QuickStartExample$y > fit <- glmnet(x, y) > print(fit)