prdm0 / ropenblas

Package to link R language to OpenBLAS library
https://prdm0.github.io/ropenblas/.
GNU General Public License v3.0
50 stars 5 forks source link

Error: package or namespace load failed for ‘stats’ #10

Closed JBGruber closed 4 years ago

JBGruber commented 4 years ago

I just gave ropenblas a try on Kubuntu 18.04. I used libopenblas-dev before and it worked fine. Now when opening R I receive the following error:

Error: package or namespace load failed for ‘stats’ in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object '/usr/lib/R/library/stats/libs/stats.so': /usr/lib/x86_64-linux-gnu/liblapack.so.3: undefined symbol: gotoblas During startup - Warning message: package ‘stats’ in options("defaultPackages") was not found Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared object '/usr/lib/R/library/stats/libs/stats.so': /usr/lib/x86_64-linux-gnu/liblapack.so.3: undefined symbol: gotoblas

I saw a couple of warning while compiling but it was succesful in the end. I thought I'll let you know. Will post a fix when I find one.

prdm0 commented 4 years ago

Firstly, thank you very much for reporting this. I will look into the next few days to try to understand what might be happening. Try removing the R and the openblas library and install them again. Then, so you can help me, run the sessionInfo() command on your system. Please return me the output.

JBGruber commented 4 years ago

I tried reinstalling r-base, removing libopenblas-dev after it didn't change anything installing libopenblas-dev again.

The error is also much more severe than I first thought. I can't even send you a sessionInfo():

> sessionInfo()
Error in La_library() : LAPACK routines cannot be loaded
In addition: Warning message:
In La_library() :
  unable to load shared object '/usr/lib/R/modules//lapack.so':
  /usr/lib/x86_64-linux-gnu/liblapack.so.3: undefined symbol: gotoblas

Basically nothing works at this point as both openblas and lapack seem to be broken. I found a couple of suggestions on SO and the OpenBLAS GitHub but nothing seems to work so far.

JBGruber commented 4 years ago

One suggestion I found is to remove the version built from source. Maybe you could advise me on how to do that? Probably also a good idea to implement something like ropenblas(remove = TRUE) in the future so people can revert to their original installation if things go wrong.

And here is a sessionInfo() from Thursday, before upgrading R and installing ropenblas

## R version 3.6.1 (2019-07-05)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 18.04.3 LTS
## 
## Matrix products: default
## BLAS:   /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
## LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so
## 
## locale:
##  [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    
##  [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
##  [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] viridis_0.5.1              viridisLite_0.3.0         
##  [3] LexisNexisTools_0.2.3.9000 scales_1.1.0              
##  [5] forcats_0.4.0              stringr_1.4.0             
##  [7] purrr_0.3.3                tidyr_1.0.0               
##  [9] DT_0.9                     ggplot2_3.2.1             
## [11] dplyr_0.8.3  
prdm0 commented 4 years ago

I use Arch Linux, but try something like:

apt-get remove --auto-remove r-base apt-get remove libopenblas-dev apt-get install blas apt-get install lapack apt-get install r-base

Restart The terminal bash and invoke R.

prdm0 commented 4 years ago

When I am on a computer, I will check everything so that I can get to the cause of the problem.I will return soon with some information. Besta regards.

JBGruber commented 4 years ago

What you describe above is what I tried before. blas and lapack are not actually packages in Kubuntu but it doesn't matter. The problem was with symlinks and incompatible versions of BLAS (for whatever reason, maybe this one).

I did several quite aggressive things to get rid of the error. I'm not sure which one helped in the end and R is using a different BLAS and LAPACK version now but this is I think what solved it:

sudo apt-get remove --purge liblapack-dev
sudo dpkg --purge libopenblas-dev
sudo update-alternatives --remove-all liblapack.so
sudo apt –-purge remove r-base
sudo apt install --reinstall libatlas3-base
sudo apt install libopenblas-dev
sudo apt install r-base

And I'm back at this:

> sessionInfo()
R version 3.6.2 (2019-12-12)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.3 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/atlas/libblas.so.3.10.3
LAPACK: /usr/lib/x86_64-linux-gnu/atlas/liblapack.so.3.10.3

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C               LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    
 [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8    LC_PAPER=en_GB.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base 

Hope you can make sense of this somehow as I'm still confused.

prdm0 commented 4 years ago

One question, in your /opt directory is there OpenBLAS installed by the package? I will try on a virtual machine to install Ubuntu with openblas-dev and try to simulate what may have happened.

JBGruber commented 4 years ago

Yes, it's installed there:

/opt$ tree OpenBLAS         
OpenBLAS
├── bin
├── include
│   ├── cblas.h
│   ├── f77blas.h
│   ├── lapacke_config.h
│   ├── lapacke.h
│   ├── lapacke_mangling.h
│   ├── lapacke_utils.h
│   └── openblas_config.h
└── lib
    ├── cmake
    │   └── openblas
    │       ├── OpenBLASConfig.cmake
    │       └── OpenBLASConfigVersion.cmake
    ├── libopenblas.a -> libopenblas_haswellp-r0.3.7.a
    ├── libopenblas_haswellp-r0.3.7.a
    ├── libopenblas_haswellp-r0.3.7.so
    ├── libopenblas.so -> libopenblas_haswellp-r0.3.7.so
    ├── libopenblas.so.0 -> libopenblas_haswellp-r0.3.7.so
    └── pkgconfig
        └── openblas.pc

6 directories, 15 files
prdm0 commented 4 years ago

There were no errors in compilation, if had occurred it would stop. Warning messages in the compilation process are normal and vary from compiler to compiler. The error that was obtained refers to some random motive which may be as described in here. This error is something specific not correlated with package functions. In such cases, what the package should do is give the chance the possibility of returning to the previous state of R and this has just been implemented. The return to the previous state is automatic. The function will check if all went well. If not, nothing will be done.

If possible, retest the package and in case of new errors I will be available to fix them. Therefore, I will be closing the topic and will open if the error persists.