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

Problem when compiling OpenBLAS #3922

Closed
Soapon opened this issue Feb 26, 2023 · 4 comments
Closed

Problem when compiling OpenBLAS #3922

Soapon opened this issue Feb 26, 2023 · 4 comments

Comments

@Soapon
Copy link

Soapon commented Feb 26, 2023

Hi, I am trying to compile OpenBLAS for abinit. Here is the tutorial:
https://docs.abinit.org/tutorial/abinit_build/#how-to-compile-blas-and-lapack

When I tried to use Make TARGET=NEHALEM, it gave me an error:

I am using a linux system with gfortran.

@Soapon
Copy link
Author

Soapon commented Feb 26, 2023

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
rm -f ?BLAT2.SUMM
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 ./sblat2 < ./sblat2.dat
rm -f ?BLAT3.SUMM
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 ./sblat3 < ./sblat3.dat
#0  0x7fe561c23ad0 in ???
#1  0x7fe561c22c35 in ???
#2  0x7fe56184251f in ???
at ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
#3  0x564dc5a490ac in ???
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 ./dblat2 < ./dblat2.dat
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 ./dblat3 < ./dblat3.dat
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 ./cblat2 < ./cblat2.dat
Segmentation fault (core dumped)
make[1]: *** [Makefile:10: level1] Error 139
make[1]: *** Waiting for unfinished jobs....
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 ./cblat3 < ./cblat3.dat
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 ./zblat3 < ./zblat3.dat
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 ./zblat2 < ./zblat2.dat
rm -f ?BLAT3.SUMM
OPENBLAS_NUM_THREADS=2 ./sblat3 < ./sblat3.dat
OPENBLAS_NUM_THREADS=2 ./dblat3 < ./dblat3.dat
rm -f ?BLAT2.SUMM
OPENBLAS_NUM_THREADS=2 ./sblat2 < ./sblat2.dat
OPENBLAS_NUM_THREADS=2 ./cblat3 < ./cblat3.dat
OPENBLAS_NUM_THREADS=2 ./dblat2 < ./dblat2.dat
OPENBLAS_NUM_THREADS=2 ./cblat2 < ./cblat2.dat
OPENBLAS_NUM_THREADS=2 ./zblat3 < ./zblat3.dat
OPENBLAS_NUM_THREADS=2 ./zblat2 < ./zblat2.dat
make[1]: Leaving directory '/home/sophia/local/src/OpenBLAS-0.3.7/test'
make: *** [Makefile:125: tests] Error 2

This is the Error

@brada4
Copy link
Contributor

brada4 commented Feb 26, 2023

Lets check your environment.

  • whats your Linux version, like from /etc/*_release files
  • cc --version and gfortran --version - they need to be same in best case
  • Not important while you force TARGET - "model name" from /proc/cpuinfo and output of nproc

To try

  • run make clean before next make TARGET=NEHALEM - if you ever ran make without parameters you have mix of 2 different CPU and parallelism codes.
  • Old versions cannot be fixed here, please try with 0.3.21 tarball from project releases

If it still fails we get into deeper debugging.

@martin-frbg
Copy link
Collaborator

martin-frbg commented Feb 26, 2023

Is there any particular reason why you need to use 0.3.7 from more than three years ago (except that this seems to have been when the tutorial was written) ? Please try to build a more recent release (substitute 0.3.21 for the 0.3.7 in the wget)

@brada4
Copy link
Contributor

brada4 commented Feb 26, 2023

Looking into instructions
make -j2 USE_THREAD=0 USE_LOCKING=1
make PREFIX=$HOME/local/ install

Second command should repeat all settings from first one:
make -j2 MAKE_NB_JOBS=-1 TARGET=NEHALEM USE_THREAD=0 USE_LOCKING=1
make MAKE_NB_JOBS=-1 TARGET=NEHALEM USE_THREAD=0 USE_LOCKING=1 PREFIX=$HOME/local/ install

If they do not match - make will build another copy of library - multithreaded, with detected CPU.
MAKE_NB_JOBS when set to negative will respect -j2 parameter, in place of running on all CPUs by default.

EDIT:
Down the road:
-L$HOME/local/lib -lopenblas
Should be
-L$HOME/local/lib -lopenblas -Wl,rpath=$HOME/local/lib
That will make executable try builtin rpath in place of default ld.so paths.

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

3 participants