NPSOL and Linux: BLAS/LAPACK routine ' DGEQR' error code -6
Posted on
janneadolf
Joined: 02/06/2015
Forums
I am having problems using NPSOL on a linux grid computing system:
After installing OpenMx via getOpenMx.R and setting NPSOL as the default optimiser I run an OpenMx demo script (e.g., OneFactorPathDemo.R) and get the following error message:
After installing OpenMx via getOpenMx.R and setting NPSOL as the default optimiser I run an OpenMx demo script (e.g., OneFactorPathDemo.R) and get the following error message:
*Error in runHelper(model, frontendStart, intervals, silent, suppressWarnings, : BLAS/LAPACK routine ' DGEQR' gave error code -6*
Things are fine when I use the other optimizers - but were also in the past with NPSOL.
After checking OpenMx/npsol directory, the person in charge of the grid generated the hypothesis that the latest OpenMx version might not include NPSOL for linux users.
Apparently, only windows and osx feature in there. Is this the case?
OpenMx version: 2.8.3 [GIT v2.8.3]
R version: R version 3.3.3 (2017-03-06)
Platform: x86_64-pc-linux-gnu (Debian GNU/Linux 9.3 (stable))
Default optimiser: NPSOL
NPSOL-enabled?: Yes
OpenMP-enabled?: Yes
gcc version?
Log in or register to post comments
In reply to gcc version? by jpritikin
The gcc version is 6.3
Log in or register to post comments
In reply to The gcc version is 6.3 by janneadolf
Looks okay?
Log in or register to post comments
In reply to The gcc version is 6.3 by janneadolf
Log from compiler, etc.?
Log in or register to post comments
In reply to Log from compiler, etc.? by AdminRobK
log file
Log in or register to post comments
In reply to log file by janneadolf
How are you installing?
I don't see anything in the log you posted that looks like an obvious sign of something wrong. How are you installing the package? I'm guessing you've locally cloned the source repository from Github, and are using 'make install' at the command shell?
Log in or register to post comments
In reply to How are you installing? by AdminRobK
Hi there!
I'm this person. :)
We were building with `source('http://openmx.psyc.virginia.edu/getOpenMx.R')` .
I tried to create a reproducible environment that generates the error and I think I found the source of the problem. It seems that the error is in combination with libopenblas, which is the default BLAS implementation on our cluster. When using the default libblas3 everything seems to work, but I'm reluctant to just ditch libopenblas because of the [peformance gains](https://www.r-bloggers.com/for-faster-r-use-openblas-instead-better-than-atlas-trivial-to-switch-to-on-ubuntu/).
Since we are currently preparing to deploy [singularity containers](http://singularity.lbl.gov/docs-build-container#building-containers-from-singularity-recipe-files) (debian pkgs available at [neurodebian](http://neuro.debian.net/pkgs/singularity-container.html)) I thought it would be a nice idea to put the erroneous environment in such a container recipe (attached). Note that this recipe will clobber the current directory with R packages.
It should be as simple as:
```
$ sudo singularity build openmx-issue-4323.simg Recipe.txt
$ singularity run openmx-issue-4323.simg
```
This also works well with vagrant on macOS.
I know that the container approach would also be the solution to the problem at hand. We could just push an oldstable debian with libopenblas and be done with it, but we're not quite there yet.
What do you suggest we do? Can we easily rebuild against libblas3 and would that hurt performance a lot?
Or is that maybe an indication for a bug in npsol that should be investigated further?
Log in or register to post comments
In reply to Hi there! by mkrause
Recipe doesn't work, sorry
Here is a container that actually works: [https://www.singularity-hub.org/containers/1471](https://www.singularity-hub.org/containers/1471)
You can download and start the compilation+test with in one go:
```
singularity run shub://octomike/singularity-containers:openmx-4323
```
Log in or register to post comments
In reply to Recipe doesn't work, sorry by mkrause
singularity
Log in or register to post comments
In reply to singularity by jpritikin
Hoping gfortran 7.2 Npsol library is on its way
Log in or register to post comments
In reply to Recipe doesn't work, sorry by mkrause
wrong link order?
$(FLIBS) $(BLAS_LIBS) $(LAPACK_LIBS) $(NPSOL_LDFLAGS)
. I have corrected the order to:$(NPSOL_LDFLAGS) $(NLOPT_LDFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
. I wonder if this will solve your problem?Log in or register to post comments
In reply to Hi there! by mkrause
Interesting. I'll be sure to
I suspect it might not be so easy, at least if you've compiled R against libopenblas. Per the R Installation and Administration Manual,
As for the performance cost, I am not entirely sure. Note that quite a bit of OpenMx's numerical linear algebra is done in its compiled C++ backend, using the Eigen library (which is not a BLAS implementation). Something you could try is to install OpenMx from CRAN (which doesn't distribute NPSOL), once with libblas3 and again with libopenblas, and compare benchmarks run under both installations. Indeed, if NPSOL isn't critical for your users' purposes, it seems the CRAN build would work OK on your system.
BTW, are you using the same LAPACK with libblas3 and libopenblas? I ask because DGEQR (the cause of the error with NPSOL) is a LAPACK subroutine.
Log in or register to post comments
In reply to Hi there! by mkrause
NPSOL
BTW, are you using the same LAPACK with libblas3 and libopenblas? I ask because DGEQR (the cause of the error with NPSOL) is a LAPACK subroutine.
P.S. We do appreciate your effort at creating a reproducible example of the issue!
Log in or register to post comments
libopenblas
update-alternatives
command, I switched the system BLAS library to be a symbolic link to libopenblas.so.3. I successfully installed R, using the following commands:./configure --enable-R-shlib --with-blas=-lblas --disable-BLAS-shlib
make
sudo make install
I then recompiled OpenMx. I reproduced the issue reported in the OP of this thread. However, after I used
update-alternatives
to switch the system BLAS library back to the reference implementation, I was able to build OpenMx with working NPSOL, without even recompiling anything (since the system BLAS library only gets involved during the linking step, not the compilation step). The key seems to be the--disable-BLAS-shlib
flag, which makes it possible to build R with one BLAS implementation but later build R packages with a different implementation--see my post earlier in the thread, in which I quote the R Installation and Administration Manual.BTW, I built R with OpenBLAS' LAPACK implementation as well.
Log in or register to post comments
success
Before compiling R, I switched my system BLAS and LAPACK libraries from the reference implementations to the OpenBLAS implementations. I ran R's 'configure' script with the following flags:
--enable-R-shlib --with-blas=-lblas --disable-BLAS-shlib --enable-memory-profiling
The first flag enables R to function as a shared library, which is necessary to use it with RStudio. The second flag says to link against the system BLAS library, instead of compiling R's BLAS code. The third says not to create a BLAS shared library against which other R packages will link at install-time, which is necessary because OpenMx doesn't appear to play nice with OpenBLAS (at least at present). The fourth is just useful to me as a developer.
Then, after installing R, I switched my system BLAS library back to the reference implementation, and built OpenMx using the new NPSOL binary. Success!
If you try to build NPSOL-enabled OpenMx from source with gcc 8, the 'make' recipe will automatically pull the new NPSOL binary from our server.
EDIT: I was wrong about a few things in this post. See my subsequent post for details.
Log in or register to post comments
update
Second, I have been testing OpenMx when it, or both it and R, have been compiled with hardware-tuned BLAS/LAPACK implementations--including the Intel MKL, OpenBLAS, and ATLAS. I should first clarify what I mean by "compiling OpenMx with hardware tuned BLAS/LAPACK implementations". As of this writing, OpenMx's backend code does not contain any calls to Fortran BLAS/LAPACK routines. However, NPSOL uses some BLAS/LAPACK routines. More to the point, the linear-algebra library OpenMx uses, Eigen, has compile-time options that allow fast BLAS/LAPACK routines to be substituted for its own functions. Thus, enabling those options is what is meant by "compiling OpenMx with hardware tuned BLAS/LAPACK implementations".
When working on the aforementioned testing, I realized two things. First, using the `--disable-BLAS-shlib` configure flag is cumbersome and unwieldy. In particular, if you want to compile OpenMx with an external BLAS, it's much simpler to compile R with it, use configure flag `--enable-BLAS-shlib`, and just have OpenMx dynamically link to R's BLAS shared library (with the necessary Eigen flags set). Second (and more importantly), I wasn't actually linking R against OpenBLAS as I thought in my preceding post, since I wasn't providing a linker path. For instance, I'm currently using ATLAS as system BLAS library, and the configure command I used to compile R with it was
./configure --with-blas="-L/usr/lib/x86_64-linux-gnu -lblas" --enable-R-shlib --enable-BLAS-shlib --enable-memory-profiling
Anyhow, compiling OpenMx with Intel MKL succeeds, whether R was linked against the reference BLAS or against MKL. Linking R against OpenBLAS, and compiling OpenMx with it, also succeeds. Linking R against ATLAS, and compiling OpenMx with it, succeeds likewise.
However, NPSOL simply does not "play nice" when R has been linked against MKL or OpenBLAS (but ATLAS is OK), irrespective of how OpenMx was compiled. We now have an NPSOL binary for Linux, compatible with gcc version 8 or newer, that does not cause compile-time errors when R has been linked against OpenBLAS. Using NPSOL with the resulting OpenMx installation does not cause LAPACK errors like the one reported in this thread, but unfortunately, will crash R for certain scripts in the OpenMx test suite. It seems that's the best we can do, at least for the time being.
Log in or register to post comments