RfastOfficial / Rfast

A collection of Rfast functions for data analysis. Note 1: The vast majority of the functions accept matrices only, not data.frames. Note 2: Do not have matrices or vectors with have missing data (i.e NAs). We do no check about them and C++ internally transforms them into zeros (0), so you may get wrong results. Note 3: In general, make sure you give the correct input, in order to get the correct output. We do no checks and this is one of the many reasons we are fast.
143 stars 19 forks source link

Unable to load dynamic library from dependency RcppZiggurat #35

Closed ntthung closed 3 years ago

ntthung commented 3 years ago

Hi!

I get the following error when running Rfast on a Linux cluster (Red Hat 6.10).

unable to load shared object '/home/users/sutd/R/x86_64-pc-linux-gnu-library/3.6/RcppZiggurat/libs/RcppZiggurat.so':
  libgsl.so.0: cannot open shared object file: No such file or directory

The packages are installed on my local directory.

I know that libgsl.so is located in /usr/lib64/, so I've added the following line at the beginning of my R script

Sys.setenv(LD_LIBRARY_PATH=paste("/usr/lib64/", Sys.getenv("LD_LIBRARY_PATH"), sep = ":"))

I have also try to do dyn.load('/usr/lib64/libgsl.so') but I get the following error

Error in dyn.load("/usr/lib64/libgsl.so") : unable to load shared object '/usr/lib64/libgsl.so': 
/usr/lib64/libgsl.so: undefined symbol: cblas_ctrmv

On Windows everything works fine.

Is this an issue or am I doing something wrong?

Thank you so much.

ntthung commented 3 years ago

Update: I've done some diagnostic and found that this only happens when the Rfast functions are being called in parallel, in a foreach() loop. When they are called directly it is OK.

ManosPapadakis95 commented 3 years ago

Hello,

Thanks for your mail. Again, this is not good behaviour. Please give me an example using foreach so I can replicate the error.

Manos

Στις Τρί, 27 Οκτ 2020 στις 10:47 π.μ., ο/η Nguyen Tan Thai Hung < notifications@github.com> έγραψε:

Update: I've done some diagnostic and found that this only happens when the Rfast functions are being called in parallel, in a foreach() loop. When they are called directly it is OK.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/RfastOfficial/Rfast/issues/35#issuecomment-717084379, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANPP3FJ63WDYQ2NNMALF2TTSM2CKTANCNFSM4TAIV6QQ .

ntthung commented 3 years ago

Hi Manos,

Thank you for getting back. And I apologize for asking multiple places. I posted here in a panic and desperate moment, A few hours later I was able to calm down and posted this question on StackOverflow. A few solutions have been offered there but none worked on my end.

Again I am very sorry for crossposting. I've learned my lesson and won't do it again.

Sincerely, Hung

ManosPapadakis95 commented 3 years ago

You don't have to apologize. I understand.

Best, Manos

Στις Τετ, 28 Οκτ 2020, 03:23 ο χρήστης Nguyen Tan Thai Hung < notifications@github.com> έγραψε:

Hi Manos,

Thank you for getting back. And I apologize for asking multiple places. I posted here in a panic and desperate moment, A few hours later I was able to calm down and posted this question on StackOverflow https://stackoverflow.com/questions/64551253/dynamic-library-dependencies-not-recognized-when-run-in-parallel-under-r-foreach. A few solutions have been offered there but none worked on my end.

Again I am very sorry for crossposting. I've learned my lesson and won't do it again.

Sincerely, Hung

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/RfastOfficial/Rfast/issues/35#issuecomment-717636561, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANPP3FNCQC4BVUM34BMBS5TSM5XB7ANCNFSM4TAIV6QQ .

ntthung commented 3 years ago

I am able to narrow the error down now. The error occurs when the RcppZiggurat package is loaded following a call to Rfast. To reproduce the error, I have an R script named test-gsl.R, which has the following two lines.

library(RcppZiggurat)
print(‘OK’)

Now, I run the following on the head node

$ module load R/3.6.3
$ Rscript test-gsl.R

And everything works fine. The ‘OK’ is printed.

But this doesn’t work if I submit the job on the compute node. First, the PBS script, called test.sh, is as follows

### Resources request
#PBS -l select=1:ncpus=1:mem=1GB

### Walltime
#PBS -l walltime=00:01:00

echo Working directory is $PBS_O_WORKDIR
cd $PBS_O_WORKDIR

### Run R
module load R/3.6.3
Rscript test-gsl.R

Then I run

qsub test.sh

And got the following error

Error: package or namespace load failed for ‘RcppZiggurat’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/home/users/sutd/1001986/R/x86_64-pc-linux-gnu-library/3.6/RcppZiggurat/libs/RcppZiggurat.so':
  libgsl.so.0: cannot open shared object file: No such file or directory
Execution halted

Somehow, on the head node, the system was able to find libgsl.so.0, but on the compute node, an error occurs.

So it seems that this has nothing to do with Rfast. It's either RcppZiggurat or my own system. I have contacted the system administrator. Hopefully they will be able to solve it. So I'd like to close the isuse. Sorry for the false alarm, and thanks for your attention.

By the way I just want to say that Rfast is really really fast! Thank you for your work.

Best, Hung