-
-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
gnss-sdr: init at 0.0.9 (and patch armadillo's buildInputs) #27505
Conversation
Afaik openblas should include all lapack routines, so I think we should check why armadillo depends on an extra library for that.
|
Huh. All I know so far is that the armadillo build reports "LAPACK_FOUND = NO" (for instance in http://hydra.nixos.org/build/56592131/log), and that adding Any suggestions on how to investigate this? (Also, I botched my |
Openblas includes an optimized implementation of Lapack. Opencv (with Openblas enabled) finds it:
|
It seems armadillo doesn't know about openBLAS's lapack functionality yet. I've filed an issue:
I've created a PR for this: #27528 |
Looking at the commit history for our armadillo derivation I just realized that this should have been fixed long ago, but I accidentally reverted it: https://github.com/NixOS/nixpkgs/commits/82e760a3d613ec9e82ab48131f8b94b1119dc535/pkgs/development/libraries/armadillo/default.nix |
@jameysharp @juliendehos @knedlsepp Unfortunately it can't be guaranteed that OpenBLAS comes with LAPACK. Last time I checked, the super-wise folks at Debian build their version of OpenBLAS without LAPACK. Debian stuff then propagates to Ubuntu, and we end up with a royal mess. Armadillo needs to support various Linux-based operating systems, so it can't assume that OpenBLAS comes with LAPACK built in. Armadillo's cmake installer simply enables LAPACK support if LAPACK is detected. If an untainted version of OpenBLAS is on the system, it should use LAPACK functions from OpenBLAS instead of standard LAPACK. This is due to the linker simply finding the appropriate functions in OpenBLAS first. In other words, in addition to OpenBLAS, I suggest having a standard version of LAPACK on the system. |
just using openblasCompat instead of openblas seems to "solve" the problem : //testarma.cpp
#define ARMA_USE_LAPACK
#define ARMA_DONT_USE_WRAPPER
#include <armadillo>
using namespace arma;
int main() {
mat U, V, X = randu<mat>(9, 9);
vec s;
svd(U,s,V,X);
return 0;
} #default.nix
with import <nixpkgs> {};
with pkgs; stdenv.mkDerivation {
name = "testarma";
src = ./.;
buildInputs = [ armadillo openblasCompat ]; # ok
#buildInputs = [ armadillo openblas ]; # svd(): decomposition failed
buildPhase = "g++ -std=c++11 -o testarma testarma.cpp -larmadillo -lopenblas";
installPhase = "mkdir -p $out/bin; cp testarma $out/bin";
} |
@juliendehos: The fix I'm proposing here in nixpkgs would mean that you could get rid of:
and |
Ok, good idea. I've tested your fix and it seems ok. Thanks. |
@jameysharp: Could you rebase your PR to exclude the armadillo lapack addition, now that the fix was merged? (#27528) |
I've rebased and re-tested just adding I also finally turned on Got any other concerns before merging this? |
@@ -0,0 +1,61 @@ | |||
{ stdenv, fetchFromGitHub | |||
, armadillo | |||
, blas |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little skeptical if including blas
and lapack
as buildInputs is correct. armadillo
links to a different BLAS version (our openblasCompat
). I suspect that they should be purged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A fair concern, but without them the build fails with one of these two messages:
The LAPACK library has not been found. You can try to install it by typing: sudo apt-get install liblapack-dev CMake Error at CMakeLists.txt:762 (message): LAPACK is required to build gnss-sdr
or
The BLAS library has not been found. You can try to install it by typing: sudo apt-get install libopenblas-dev CMake Error at CMakeLists.txt:783 (message): BLAS is required to build gnss-sdr
Also, I tested building with both openblasCompat
and openblas
, and the configure script failed to detect either one. It only accepts blas
. Which is funny since the Debian package it helpfully suggests installing is for openblas...
I don't understand any of the relevant code well enough to guess what the right fix is. In particular, I haven't worked with lapack/blas before, but I'm also not super comfortable with cmake. Any suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at their CMakelists.txt. It seems they do the following:
- Require CMake finds LAPACK
- Require CMake finds BLAS
- Try to find armadillo
- If it is not found, build it with the previously found LAPACK and BLAS
- If it is found, just use it and ignore which LAPACK and BLAS was actually found previously.
So I think that by adding lapack and blas to the derivation, we actually just pass the first two stages and then drop the found lapack and blas. I think we could get this working by just forcing CMake to pass these first two stages via:
cmakeFlags = [ "-DBLAS=YES" "-DLAPACK=YES" ];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Closer look also reveals that the same goes probably for gfortran
and -D GFORTRAN=YES
description = "An open source Global Navigation Satellite Systems software-defined receiver"; | ||
homepage = http://gnss-sdr.org/; | ||
license = licenses.gpl3Plus; | ||
platforms = platforms.unix; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to build this on darwin
, but at least one of the dependencies requires linux
currently, so unless we can get it to work on macOS this should be changed to platforms.linux
in the meantime.
I've tested the resulting build against the sample "2013_04_04_GNSS_SIGNAL_at_CTTC_SPAIN" dataset linked from: http://gnss-sdr.org/my-first-fix/ Many thanks to @knedlsepp for suggestions in NixOS#27505 that have substantially improved this package!
You're absolutely right @knedlsepp, thanks! I've tested and pushed your suggested fixes. Do you think this is ready to merge now? |
Looks good to me. 🍻 |
Thanks! |
And thank you too, @Mic92! |
I've tested the resulting build against the sample "2013_04_04_GNSS_SIGNAL_at_CTTC_SPAIN" dataset linked from: http://gnss-sdr.org/my-first-fix/ Many thanks to @knedlsepp for suggestions in NixOS#27505 that have substantially improved this package!
Motivation for this change
This open-source implementation of a software-defined radio receiver for GPS and other GNSS signals was not yet packaged.
In order to get a usable build of
gnss-sdr
, I had to changearmadillo
'sbuildInputs
to addliblapack
; otherwise several important functions fail at runtime. Perhaps @juliendehos or @knedlsepp will want to comment on that change?I've tested the resulting
gnss-sdr
binary against the sample2013_04_04_GNSS_SIGNAL_at_CTTC_SPAIN
dataset linked from http://gnss-sdr.org/my-first-fix/.Things done
(nix.useSandbox on NixOS,
or option
build-use-sandbox
innix.conf
on non-NixOS)
nix-shell -p nox --run "nox-review wip"
./result/bin/
)