AU-BCE-EE / PRIME-issues

0 stars 0 forks source link

R package installation problems #1

Open sashahafner opened 11 months ago

sashahafner commented 11 months ago

One we dealt with today. .bashrc file had the default R library set with . . . (@J-Kamp can you add it in a comment below?) It was to a directory that didn't exist. Fixed by simply making the directory e.g., with

mkdir xxx

in Bash.

Important point is that this setting won't show up in R or .Rprofile, so remember to check .bashrc too.

J-Kamp commented 11 months ago

The issue is regarding R running on PRIME (https://mpe.au.dk/en/research/facilities/prime) that is a Linux based cluster computer. R was installed on /com/ (common) folder available for all BCE users (installed by JK in 2019).

Create bash-files in user directory to make a shourt cut for R:

.bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

alias R=/com/bceairq/R/4.0.1/bin/R
alias Rscript=/com/bceairq/R/4.0.1/bin/Rscript

export LD_LIBRARY_PATH=/com/bceairq/src/geos/lib/:$LD_LIBRARY_PATH

#export LD_RUN_PATH=/path/to/lib1:/path/to/lib2:/path/to/lib3
#export LD_RUN_PATH=$LD_LIBRARY_PATH:/com/bceairq/src/geos/lib/

# User specific aliases and functions

# classify files in colour
alias ls='ls -hF --color=auto -a'
# list all but . and ..
alias la='ll -A'

# add site library (ask christoph haeni ;)
export R_LIBS_USER=~/.R/site-library

# change dir color
LS_COLORS='rs=0:di=01;94:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:';

Issue was that the directory. "~/.R/site-library" was not created and should be created manually.

.bash

#!/bin/sh
LD_LIBRARY_PATH=/com/bceairq/src/geos/lib/:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
exec /com/bceairq/R/4.0.1/bin/R
exec /com/bceairq/R/4.0.1/bin/Rscript $@

env LD_LIBRARY_PATH=/com/bceairq/src/geos/lib/:$LD_LIBRARY_PATH R

Issue on rgeos

There is on issue on installing rgeos, same issue as described here: https://stackoverflow.com/questions/53389181/installing-the-r-package-rgeos-on-linux-geos-config-not-found-or-not-executab

Solved: Frist install geos and search for the library:

cd /temp/geos/
wget http://download.osgeo.org/geos/geos-3.6.1.tar.bz2
tar -vxjf geos-3.6.1.tar.bz2
cd geos-3.6.1
./configure --prefix=/com/bceairq/src/geos
make
make check
make install

export LD_LIBRARY_PATH=/com/bceairq/src/geos/lib/:$LD_LIBRARY_PATH_

IN R:

install.packages("rgeos", configure.args =
"--with-geos-config=/com/bceairq/src/geos/bin/geos-config")

## RcppParallel installation
_**Is this the cause?**_
I think this error happens if the working directory is not the package root (https://github.com/r-lib/rcmdcheck/issues/14):
_> getwd()
>  rcmdcheck(getwd())
Error: No root directory found in /home/jk or its parent directories. Root criterion: contains a file "DESCRIPTION" with contents matching "^Package: "
J-Kamp commented 11 months ago

.Rprofile

slurm/prime stuff

options(
    #bls.slurm.jobdir = '/scratch',
    bls.slurm.exclude.partition = 'q32g'
)

terminal appearance

colorize terminal output (https://github.com/jalvesaq/colorout)

if(interactive()) {
    require(colorout)

    # my colors
    setOutputColors(
        normal = 109,
        number = 172,
        negnum = 167,
        zero = 226,
        date = 179,
        string = 117,
        const = 131,
        false = 202,
        true = 150,
        infinite = 123,
        index = 30,
    #     stderror = 213,
    #     warn = c(1, 16, 196),
    #     error = c(160, 231),
    #     zero.limit = NA,
        verbose = FALSE
    )

    # custom patterns (copied from https://gist.github.com/kar9222/0e1130c15bfaba3a71f0cf6d1d08931f)
    # custom patterns data.table
    colorout::addPattern('[0-9]*:',  '\x1b[38;2;143;188;187m')  # Row num
    colorout::addPattern('---',      '\x1b[38;2;76;86;106m')    # Row splitter
    colorout::addPattern('<[A-z]*>', '\x1b[38;2;143;188;187m')  # Col class

    # custom patterns str
    ## List
    colorout::addPattern('List of [0-9]*', '\x1b[38;2;235;203;139;48;2;76;86;106;1m')
    ## Class
    colorout::addPattern(' num ',          '\x1b[38;2;143;188;187m')
    colorout::addPattern(' int ',          '\x1b[38;2;143;188;187m')
    colorout::addPattern(' dbl ',          '\x1b[38;2;143;188;187m')
    colorout::addPattern(' chr ',          '\x1b[38;2;143;188;187m')
    colorout::addPattern(' logi ',         '\x1b[38;2;143;188;187m')
    colorout::addPattern(' lglc ',         '\x1b[38;2;143;188;187m')
    colorout::addPattern(' Factor ',       '\x1b[38;2;143;188;187m')
    colorout::addPattern(' Ord.factor ',   '\x1b[38;2;143;188;187m')
    colorout::addPattern(' POSIXct, ',     '\x1b[38;2;143;188;187m')
    colorout::addPattern('function ',      '\x1b[38;2;143;188;187m')
    colorout::addPattern(' lgcl ',         '\x1b[38;2;143;188;187m')
    colorout::addPattern(' Factor ',       '\x1b[38;2;143;188;187m')
    colorout::addPattern(' Ord.factor ',   '\x1b[38;2;143;188;187m')
    colorout::addPattern(' POSIXct, ',     '\x1b[38;2;143;188;187m')
    colorout::addPattern('function ',      '\x1b[38;2;143;188;187m')
    colorout::addPattern(' lgcl ',         '\x1b[38;2;143;188;187m')
    colorout::addPattern(' cplx ',         '\x1b[38;2;143;188;187m')
    # Misc
    colorout::addPattern('$ ',             '\x1b[38;2;76;86;106m')
    # comments
    colorout::addPattern('#[ -~]*',             '\x1b[38;2;76;86;106m')
}

add "aliases" ----------------------------------------

exit R

exit <- structure(list(), class = "hac5_exit")
print.hac5_exit <- function(x, ...) q("no")

clear workspace

.create_clear <- function(fun){
    fu_name <- deparse(substitute(fun))
    bf <- body(fun)
    bf[4] <- bf[3]
    bf[3] <- parse(text =
        paste0(
        'Kill <- List[!(List %in% c(',
        paste0('"', ls(envir = .GlobalEnv), '"', collapse = ', '),
        '))]')
        )
    body(fun) <- bf
    assign(fu_name, fun, envir = .GlobalEnv)
}

clear <- structure(list(), class = "hac5_clear")
print.hac5_clear <- function(x, ...) {
    List <- ls(envir = .GlobalEnv)
    rm(list = Kill, envir = .GlobalEnv)
}

close all devices

goff <- structure(list(),class="hac5_goff")
print.hac5_goff <- function(x,...)graphics.off()

pseudo bash mode (passing command line to system)

sh <- structure(function(path = getwd()){
    if (!dir.exists(path) && dir.exists(dn <- dirname(path))) {
        path <- dn
    } else if(!dir.exists(path)) {
        path <- getwd()
    }
    system(paste0('bash -c "cd ', path, '; bash --rcfile <(cat ~/.bashrc; echo \\"PS1=\'\\033[1;31m \\w $\\033[0m \'\\")"'))
    invisible(NULL)
}, class = "hac5_shell")
print.hac5_shell <- function(x, ...){
    sh()
    invisible(NULL)

}

set column width of terminal

widescreen <- structure(list(),class="hac5_widescreen")
print.hac5_widescreen <- function(x,...) options(width=as.integer(Sys.getenv("COLUMNS")))

if(interactive())options(width=system("tput cols", intern=TRUE))

general settings

options(
    # help as text
    help_type = "text",
    # don't use annoying guis to select from choices
    menu.graphics = FALSE
)

set CRAN mirror

local({
    r <- getOption("repos")
    r["CRAN"] <- "https://cloud.r-project.org"
    options(repos = r)
})

initialize objects

## create clear object
.create_clear(print.hac5_clear)
rm(.create_clear)
sashahafner commented 11 months ago

Good news on rgeos!

Hate to say it but it would be good to upgrade a 2019 version of R.

J-Kamp commented 11 months ago

New version of R

R has been installed in my personal folder (/home/jk/R/4.3.1)

Packages installed

Packages has been installed, including devtools

rgeos issue

Still issues with rgeos: solved

Frist install geos:

cd /temp/geos/
wget http://download.osgeo.org/geos/geos-3.6.1.tar.bz2
tar -vxjf geos-3.6.1.tar.bz2
cd geos-3.6.1
./configure --prefix=/com/bceairq/src/geos
make
make check
make install

 export LD_LIBRARY_PATH=/com/bceairq/src/geos/lib/:$LD_LIBRARY_PATH

IN R: install.packages("rgeos", configure.args = "--with-geos-config=/com/bceairq/src/geos/bin/geos-config")

RcppParallel issue

Error: package or namespace load failed for 'RcppParallel':
 .onLoad failed in loadNamespace() for 'RcppParallel', details:
  call: dyn.load(file, DLLpath = DLLpath, ...)
  error: unable to load shared object '/home/jk/R/4.3.1/lib64/R/library/00LOCK-RcppParallel/00new/RcppParallel/libs/RcppParallel.so':
  /home/jk/R/4.3.1/lib64/R/library/00LOCK-RcppParallel/00new/RcppParallel/libs/RcppParallel.so: undefined symbol: _ZN3tbb10interface58internal9task_base7destroyERNS_4taskE
Error: loading failed

Possible solution: https://github.com/RcppCore/RcppParallel/issues/97

export tbb_os=linux
export arch=x86_64
R CMD INSTALL /home/jk/RcppParallel_5.1.7.tar.gz

Not working:

Error: package or namespace load failed for 'RcppParallel':
 .onLoad failed in loadNamespace() for 'RcppParallel', details:
  call: dyn.load(file, DLLpath = DLLpath, ...)
  error: unable to load shared object '/home/jk/R/4.3.1/lib64/R/library/00LOCK-RcppParallel/00new/RcppParallel/libs/RcppParallel.so':
  /home/jk/R/4.3.1/lib64/R/library/00LOCK-RcppParallel/00new/RcppParallel/libs/RcppParallel.so: undefined symbol: _ZN3tbb10interface58internal9task_base7destroyERNS_4taskE

Posible solution: https://github.com/RcppCore/RcppParallel/issues/189 Add file 'Makevars' to ~/4.3.1/lib64/R/etc/ containg: CXX11 = /gsc/software/linux-x86_64-centos7/gcc-7.2.0/bin/g++ Add file 'Makevars' to ~/.R/ containg: CXX11 = /gsc/software/linux-x86_64-centos7/gcc-7.2.0/bin/g++