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

Add LAPACK binary dependency #7

Closed
ahojukka5 opened this issue Sep 16, 2019 · 15 comments · Fixed by #22
Closed

Add LAPACK binary dependency #7

ahojukka5 opened this issue Sep 16, 2019 · 15 comments · Fixed by #22

Comments

@ahojukka5
Copy link
Member

No description provided.

@TeroFrondelius
Copy link
Member

Can you use Blas/Lapack from LinearAlgebra, I mean the one that comes with julia?

@ahojukka5
Copy link
Member Author

Good question. I don't know. I guess I managed to handle BLAS dependency by adding OpenBLAS to dependency list, but I think we also need LAPACK. I think the question is that is there BLAS and/or LAPACK development files available inside the cross-compile environment?

@krometis
Copy link

krometis commented Oct 16, 2020

Do you have any pointers about how to tweak the build to point to LAPACK? When I build Gmsh this error message is in the logs:

$ grep -i blas -A1 ~/.julia/packages/Gmsh/eZVOZ/deps/usr/logs/gmsh.log
-- Could NOT find BLAS (missing: BLAS_LIBRARIES) 
CMake Warning at CMakeLists.txt:495 (message):
  Could not find Blas or Lapack: most meshing algorithms will not be
  functional

and presumably as a result, when I try to generate a mesh, I get

Error   : Singular value decomposition requires LAPACK

and then a segfault. I'm building on a cluster, so my linear algebra libraries are installed in non-standard locations. Do you have pointers about how I can point Gmsh/BinaryBuilder to the right directories/libraries? I see the cmake command here but I can't figure out where that file is so I can edit it.

@ahojukka5
Copy link
Member Author

I think the right way to go is to use binary dependencies, just like with OpenBLAS

@TeroFrondelius
Copy link
Member

@krometis
Copy link

krometis commented Oct 20, 2020

I think what I'm struggling with is how to edit build_tarballs.jl. That file is part of GmshBuilder, but it's not clear to me how that gets called when I run ]add Gmsh (or ]build Gmsh). It doesn't appear to be anywhere in my .julia directory, for example:

$ find ~/.julia -name build_tarballs.jl
$

The only mention of GmshBuilder is here, which appears to only be used to download the source code:

$ grep -R -i GmshBuilder ~/.julia
/home/jkrometi/.julia/packages/Gmsh/eZVOZ/deps/build.jl:bin_prefix = "https://github.com/ahojukka5/GmshBuilder/releases/download/v4.4.1"

I can of course clone the GmshBuilder repo and edit build_tarballs.jl. But how do I get that local version to be used when I run ]add Gmsh? I apologize if this is a silly question but what Julia is doing under the hood here is very opaque to me.

(In addition, it's maybe worth mentioning that I have also Gmsh installed separately. So if I can just point Gmsh.jl to that installation, I'm also happy to do that.)

@TeroFrondelius
Copy link
Member

The package downloads pre-build binaries from here: https://github.com/ahojukka5/GmshBuilder/releases/tag/v4.4.1. The changes in building binaries should be made there. Download the tar file and check the structure. Use ln to link missing libraries.

@krometis
Copy link

Oh I see now. It's just downloading prebuilt binaries and the Linux version is missing BLAS/LAPACK:

$ wget https://github.com/ahojukka5/GmshBuilder/releases/download/v4.4.1/gmsh.v4.4.1.x86_64-linux-gnu.tar.gz
$ mkdir gmsh.v4.4.1.x86_64-linux-gnu
$ tar xzf gmsh.v4.4.1.x86_64-linux-gnu.tar.gz -C gmsh.v4.4.1.x86_64-linux-gnu/
$ egrep -i 'blas|lapack' gmsh.v4.4.1.x86_64-linux-gnu/logs/gmsh.log 
-- Could NOT find BLAS (missing: BLAS_LIBRARIES) 
  Could not find Blas or Lapack: most meshing algorithms will not be

By contrast, the Mac version has BLAS/LAPACK:

$ wget https://github.com/ahojukka5/GmshBuilder/releases/download/v4.4.1/gmsh.v4.4.1.x86_64-apple-darwin14.tar.gz
$ mkdir gmsh.v4.4.1.x86_64-apple-darwin14
$ tar xzf gmsh.v4.4.1.x86_64-apple-darwin14.tar.gz -C gmsh.v4.4.1.x86_64-apple-darwin14
$ egrep -i 'blas|lapack' gmsh.v4.4.1.x86_64-apple-darwin14/logs/gmsh.log 
-- Found Blas[veclib]
-- Found Lapack[veclib]
--  * Build options: 64Bit Blas[veclib] Dlopen Lapack[veclib] Mesh TetGen/BR

I have been working with a colleague on some code using Gmsh and it was working for him and not for me. I assumed this was because he was on a desktop and I was on a cluster. But it turns out to be because he's on a Mac and I'm on Linux. I guess I need to edit build.jl to point it to the source tarball instead or maybe bypass all of this and just point to my external installation.

@krometis
Copy link

krometis commented Oct 22, 2020

Okay it appears to be working now after the following steps (here $gmshdir is where I wanted gmsh ultimately installed):

  1. Install gmsh in a separate location. This was straightforward - I made sure that OpenBLAS was in my library path and then:
wget wget http://gmsh.info/src/gmsh-4.4.1-source.tgz #download
tar xzf v4.4.1.tar.gz #untar
cd gmsh-4.4.1-source
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=$gmshdir -DDEFAULT=0 -DENABLE_BUILD_SHARED=1 -DENABLE_MESH=1 ..
  1. Symlink lib to lib64 since my installation created lib64 but Gmsh.jl looks for lib:
ln -s 'lib64' $gmshdir/lib
  1. Remove the Gmsh.jl gmsh installation and symlink to my external gmsh installation (~/.julia/packages/Gmsh/eZVOZ is where Gmsh.jl was installed in my case):
cd ~/.julia/packages/Gmsh/eZVOZ/deps
rm -rf usr
ln -s "$gmshdir" usr

I could have not removed all of deps/usr and instead just symlinked the gmsh library itself but it just seemed cleaner/safer to symlink the whole directory.

Thank you both for your help with this!

@ahojukka5
Copy link
Member Author

Hmm, so you didn't use a cross-compiling environment used in BinaryBuilder to make the binary at all?

@krometis
Copy link

krometis commented Oct 22, 2020

No, I didn't - I just made sure that Julia and gmsh were built with the same compiler and other dependencies and it seemed to work, at least in initial testing. Is not using BinaryBuilder going to come back to bite me at some point?
(Note: Not using BinaryBuilder was not a strategic choice - I just haven't used it before and figured I could build gmsh pretty easily on my own, so I just went ahead with that.)

@ahojukka5
Copy link
Member Author

Likely not, but it doesn't generalize. Thus we cannot use it to create binaries that should work for all. If we generate the binaries using BinaryBuilder, we can then distribute the binaries and everyone can easily install Gmsh.jl.

@stevengj
Copy link

It looks like this is still an issue with the JLL binary? My students tell me that the Mac version has LAPACK but the Linux version gives a "LU factorization and substitution requires LAPACK" error.

I don't see any mention of a LAPACK or OpenBLAS dependency in the Yggdrasil build script, it seems like this needs to be added?

Should this issue be re-opened?

@fredrikekre
Copy link
Collaborator

fredrikekre commented Jun 28, 2022

Did they run on master? There haven't been a release of thsi package in a while. Edit: JuliaRegistries/General#63264

@stevengj
Copy link

Thanks! Yes, updating to the latest version fixed the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants