Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M2 not finding openblas? #2767

Closed
beew opened this issue Feb 6, 2023 · 9 comments
Closed

M2 not finding openblas? #2767

beew opened this issue Feb 6, 2023 · 9 comments

Comments

@beew
Copy link

beew commented Feb 6, 2023

OS is Ubuntu 22.04

I am trying to build M2 with openblas.

I have a copy of openblas in /opt/OpenBLAS. I have made symlinks to /usr/local/lib/pkgconfig, /usr/local/lib/openblas and /usr/local/include/openblas. I also created a file openblas.conf in /etc/ld.so.config.d with path to openblas's lib.

I also built sage from source, the configurations above were enough for sage to find openblas and build with it (actually it didn't even need all the symlinks, just linking openblas.pc to /usr/local/lib/pkgconfig and creating the conf file in /etc/ld.so.config.d were enough)

However M2's configure script apparently can't find openblas

checking whether the Accelerate framework for lapack is available... no
configure: using BLASLIBS          = 
configure: using LAPACKLIBS        = 

I then did this and ran configure again, still no difference

export CPPFLAGS="-I/usr/local/include/openblas"   
export LDFLAGS="-L/usr/local/lib/openblas"

What did I do wrong?

@mahrud
Copy link
Member

mahrud commented Feb 6, 2023

It's a long-standing issue (#475) that the autotools build doesn't have the facilities to link with openblas. Try using the cmake build instead.

@beew
Copy link
Author

beew commented Feb 6, 2023

Hi,
I am trying to build with cmake, I get

## Library information
Linear Algebra    = /usr/lib/x86_64-linux-gnu/libblas.so;-lm;-ldl

The path /usr/lib/x86_64-linux-gnu/libblas.so is created by update-alternatives and points to whatever blas that is set to default (right now the default is intel-mkl) So would M2 be dynamically linked to whatever blas set to be default at runtime? Do I need to build it specially against openblas by updating alternatives to openblas for building?

Also I get this error

CMake Error at cmake/build-libraries.cmake:10 (cmake_policy):
  Policy "CMP0135" is not known to this version of CMake.
Call Stack (most recent call first):
  CMakeLists.txt:71 (include)

My cmake version is 3.22.1

Edited: fix the cmake error by switching to cmake3.25.2

@mahrud
Copy link
Member

mahrud commented Feb 7, 2023

Do I need to build it specially against openblas by updating alternatives to openblas for building?

That should work; you can also try running cmake -DBLA_VENDOR=OpenBLAS (see here).

@beew
Copy link
Author

beew commented Feb 7, 2023

Hi

I run ninja build-programs

ninja build-programs
[1/2] Performing build step for 'build-cohomcalg'
FAILED: libraries/cohomcalg/src/build-cohomcalg-stamp/build-cohomcalg-build /home/bernard/src/M2/M2/BUILD/build/libraries/cohomcalg/src/build-cohomcalg-stamp/build-cohomcalg-build 
cd /home/bernard/src/M2/M2/BUILD/build/libraries/cohomcalg/build && LD_LIBRARY_PATH=/home/bernard/src/M2/M2/BUILD/build/usr-host/lib: /usr/bin/gmake -j8-DBUILD_docS=ON prefix=/home/bernard/src/M2/M2/BUILD/build/usr-host "CPPFLAGS=-DSING_NDEBUG -DOM_NDEBUG -DNDEBUG " "CFLAGS=-march=native -Wuninitialized -g3 -I/home/bernard/src/M2/M2/BUILD/build/usr-host/include -I/home/bernard/src/M2/M2/include -I/home/bernard/src/M2/M2/BUILD/build/include -w -Wimplicit -Werror" "CXXFLAGS=-march=native -Wuninitialized -g3 -I/home/bernard/src/M2/M2/BUILD/build/usr-host/include -I/home/bernard/src/M2/M2/include -I/home/bernard/src/M2/M2/BUILD/build/include -std=gnu++11 -w -Wno-mismatched-tags -Wno-deprecated-register" "LDFLAGS=-march=native -g3 -L/home/bernard/src/M2/M2/BUILD/build/usr-host/lib" CC=/usr/bin/cc LD=/usr/bin/c++ && /home/bernard/opt/cmake325/bin/cmake -E touch /home/bernard/src/M2/M2/BUILD/build/libraries/cohomcalg/src/build-cohomcalg-stamp/build-cohomcalg-build
gmake: the '-j' option requires a positive integer argument

I find the instructions very confusing.

the sections "quick start" and "building Macaulay2" are not exactly the same.

In step 3, where do you run the cmake -DBUILD_LIBRARIES ..., is it in step2 along with cmake -DINSTALL_PREFIX etc or separately before ninja-build ..?

and then in the same section "To enforce building certain libraries, for instance BDWGC and MPIR,...: Where is a list of all libraries? Is there anything like ./configure --help in autoconf where you are shown what options are availiable? (like to build with or without whatever libs, to enable or disable stuffs...)

Thanks.

@mahrud
Copy link
Member

mahrud commented Feb 7, 2023

I find the instructions very confusing.

Please feel free to improve any part that's not clear. There is also a a less formal guide here.

the sections "quick start" and "building Macaulay2" are not exactly the same.

Yes, they aren't meant to be the same. It might help to check out a cmake tutorial.

In step 3, where do you run the cmake -DBUILD_LIBRARIES ..., is it in step2 along with cmake -DINSTALL_PREFIX etc or separately before ninja-build ..?

Whenever you run any cmake command, it updates certain build flags or options, so you may run them whenever you want, then run ninja to build with those options. If anything doesn't work, update the appropriate flags or options by running cmake again, then try building again.

and then in the same section "To enforce building certain libraries, for instance BDWGC and MPIR,...: Where is a list of all libraries?

At the top of the instructions. Here is everything M2 itself needs:

set(PKGLIB_LIST FFLAS_FFPACK GIVARO)
set(LIBRARIES_LIST MPSOLVE FROBBY FACTORY FLINT NTL MPFI MPFR MP BDWGC LAPACK)
set(LIBRARY_LIST READLINE HISTORY GDBM ATOMICOPS)

Is there a reason you want to build the libraries yourself rather than use the ones provided by Ubuntu or linuxbrew?

@beew
Copy link
Author

beew commented Feb 7, 2023

Hi,

Can you help me resolve this? I ran teps 1 -4 in the instructions but ninja build-programs errored out

Here are my steps:

  1. just clone the repo recursively

  2. cmake -GNinja -S../.. -B. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME/opt/M2 -DBUILD_SHARED_LIBS=ON -DPARALLEL_JOBS=8-DBUILD_docS=ON -DBLA_VENDOR=OpenBLAS

3)ninja build-libraries
#this step does nothing apparently it just rerun 2) one more time

4)ninja M2-binary M2-core

Then 5) njnja build-programs failed.

ninja build-programs
[1/2] Performing build step for 'build-cohomcalg'
FAILED: libraries/cohomcalg/src/build-cohomcalg-stamp/build-cohomcalg-build /home/bernard/src/M2/M2/BUILD/build/libraries/cohomcalg/src/build-cohomcalg-stamp/build-cohomcalg-build 
cd /home/bernard/src/M2/M2/BUILD/build/libraries/cohomcalg/build && LD_LIBRARY_PATH=/home/bernard/src/M2/M2/BUILD/build/usr-host/lib: /usr/bin/gmake -j8-DBUILD_docS=ON prefix=/home/bernard/src/M2/M2/BUILD/build/usr-host "CPPFLAGS=-DSING_NDEBUG -DOM_NDEBUG -DNDEBUG " "CFLAGS=-march=native -Wuninitialized -g3 -I/home/bernard/src/M2/M2/BUILD/build/usr-host/include -I/home/bernard/src/M2/M2/include -I/home/bernard/src/M2/M2/BUILD/build/include -w -Wimplicit -Werror" "CXXFLAGS=-march=native -Wuninitialized -g3 -I/home/bernard/src/M2/M2/BUILD/build/usr-host/include -I/home/bernard/src/M2/M2/include -I/home/bernard/src/M2/M2/BUILD/build/include -std=gnu++11 -w -Wno-mismatched-tags -Wno-deprecated-register" "LDFLAGS=-march=native -g3 -L/home/bernard/src/M2/M2/BUILD/build/usr-host/lib" CC=/usr/bin/cc LD=/usr/bin/c++ && /home/bernard/opt/cmake325/bin/cmake -E touch /home/bernard/src/M2/M2/BUILD/build/libraries/cohomcalg/src/build-cohomcalg-stamp/build-cohomcalg-build
gmake: the '-j' option requires a positive integer argument

I can't use the ubuntu version because it tries to remove Singular.

Also I want to build against a fast blas. I never use the system blas, it is too slow. An operation in R or octave that takes 1.5 to 2 seconds with mkl or openblas takes almost a minute in system blas.

@mahrud
Copy link
Member

mahrud commented Feb 7, 2023

The command you run in step 2 has some missing spaces, for instance here:

-DPARALLEL_JOBS=8-DBUILD_docS=ON

which leads to:

gmake -j8-DBUILD_docS=ON

hence the error.

@beew
Copy link
Author

beew commented Feb 7, 2023

Hi, thanks for your help! It was a stupid mistake on my part.

It is now built and installed successfully. However there are a bunch of errors in running the ctests (39 failed)

1:M2-unit-tests_NOT_BUILT
2:memtailor-unit-tests_NOT_BUILT
3:mathic-unit-tests_NOT_BUILT
4:mathicgb-unit-tests_NOT_BUILT
49:normal/command.m2
332:normal/threads.m2
364:goals/ISSAC-97.m2
365:goals/gbZZ.m2
366:goals/joswig.m2
367:quarantine/2-homog-bug.m2
368:quarantine/C05.m2
369:quarantine/HH.m2
370:quarantine/issac-97.m2
371:quarantine/ker8.m2
372:quarantine/lapack.m2
373:quarantine/newlines.m2
375:quarantine/testmulti.m2
381:engine/normal.m2
391:engine/raw-monomial.m2
393:engine/raw-numerics.m2
394:engine/raw-res.m2
395:engine/raw-ring.m2
396:engine/raw-ring2.m2
399:engine/raw-subduction.m2
402:engine/raw.m2
403:engine/raw3.m2
407:engine/test-linalg.m2
410:ComputationsBook/completeIntersections
411:ComputationsBook/constructions
412:ComputationsBook/d-modules
413:ComputationsBook/exterior-algebra
414:ComputationsBook/geometry
415:ComputationsBook/monomialIdeals
416:ComputationsBook/preface
417:ComputationsBook/programming
418:ComputationsBook/schemes
419:ComputationsBook/solving
420:ComputationsBook/toricHilbertScheme
421:ComputationsBook/varieties

Not sure how concerning that is.

Again thanks.

@mahrud
Copy link
Member

mahrud commented Feb 7, 2023

Hi, thanks for your help! It was a stupid mistake on my part.

No worries. Again, feel free to make a pull request to improve the instructions if there are any changes that would improve clarity.

However there are a bunch of errors in running the ctests (39 failed)

I believe most of those are known issues (e.g. engine tests that broke after a change in the engine), see #1213.

@mahrud mahrud closed this as completed Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants