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
dnnl: init at 1.0.2 #68014
dnnl: init at 1.0.2 #68014
Conversation
23536b2
to
ca052a6
Compare
ca052a6
to
d6535c7
Compare
@jonringer Do you know if my patch to change /bin/bash to /bin/sh is the correct thing to do? would it be better to hard link to bash via storepath |
I personally would do a substitueAll, see pyproj/default.nix and the related patch as an example |
Removing the checkPhase did not fix the tests, should I just set |
the tests are failing because of:
We just need the tests to link against the shared library that gets produced. |
Do you know how to do that? |
The shared libraries seem to be written to
|
also, take note that this library may be highly coupled to intel processors, it might not work for AMD. |
I'll try that in a bit, my laptop is Intel I think and the tests worked in a nix shell |
d6535c7
to
ee4c957
Compare
More tests pass but not all of them |
ee4c957
to
d129194
Compare
All test pass now, thanks for all the help |
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.
Don't forget to resolve conversations if you made the suggested changes :)
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.
nix-review
passes on NixOS
diff LGTM (Although should squash all changes to a single commit)
leaf package
[1 built, 0.0 MiB DL]
https://github.com/NixOS/nixpkgs/pull/68014
1 package were build:
mkldnn
[nix-shell:~/.cache/nix-review/pr-68014-1]$ nix path-info -Sh ./results/mkldnn
/nix/store/r22kq0jvvxgndcyywvddgcm7sfc2cq4n-mkldnn-1.0.2 48.8M
Shall I add myself as a maintainer? |
It's up to you, but since you're familiar with how to build it to some degree, i would say that's some familiarity. Ideally a maintainer is someone with a vested interest in using the package as well. |
f0369dc
to
abfef23
Compare
The issue also mentioned adding this to the |
it's a shared library, it would need to be added to build inputs |
you need to add yourself as a maintainer see c3c8f17#diff-498fa90aaf17420b9719f0b04e1c3d08 for an example your commit history should look like:
|
The issue isn't that I'm not a maintainer, it's that I was tired and didn't write |
abfef23
to
c8d257b
Compare
inherit bash; | ||
}) ]; | ||
|
||
nativeBuildInputs = [ cmake ]; |
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.
mkl-dnn
can optionally be built against the mkl
package:
https://github.com/intel/mkl-dnn/blob/master/cmake/MKL.cmake
This has a proprietary license so it's not built/distributed by default in NixPkg and Hydra, but it is packaged. For users who want to use it it might be nice to give them an optional switch, like we do with numpy
:
https://nixos.org/nixpkgs/manual/#how-to-use-intels-mkl-with-numpy-and-scipy
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 slightly confused, should this have blas as an input?
c8d257b
to
60c2ebe
Compare
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've attempted to provide details on integrating Intel MKL below.
addAutoPatchelfSearchPath $PWD/src | ||
autoPatchelf tests examples | ||
''; | ||
|
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.
cmake should be able to find them if you override the install directory:
cmakeFlags = [
"-DMAKE_INSTALL_PREFIX=$out"
];
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.
This doesn't seem to work
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.
The checkPhase runs after build, but before install, so $out should still be empty when this gets called
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.
Another options would be
preCheck = ''export LD_LIBRARY_PATH=$PWD/src:$LD_LIBRARY_PATH'';
When i tried originally, i left off the export, and that seems to make a difference in some cases.
Problem with this, is that during the fixup, it might then discover the built shared libraries and try to link against them in the build directory, which is not what we want, and the derivation will fail
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.
perhaps:
checkPhase = ''
LD_LIBRARY_PATH=$PWD/src:$LD_LIBRARY_PATH make check
'';
would work best
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.
strangely I didn't need to do anything when I built it in a nix-shell
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.
if you did nix-shell --pure
then that might not be the case.
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.
even then it works, I can't work it out. I even messed around to get it to run tree in the checkphase and all the files look identical
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.
well, if it works, then it works. I just remember getting the "libdnn.so" cannot be found error
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.
In a nutshell, I believe the behavior is broken because of CMAKE_SKIP_BUILD_RPATH=ON
(Nix open issue and workarounds here: #22060).
I think you can resolve this with your solution or adopt one of the others from that thread.
60c2ebe
to
6cac33c
Compare
|
||
nativeBuildInputs = [ cmake ]; | ||
|
||
buildInputs = lib.optional (mkl != null) mkl; |
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.
Would something like this be appropriate here?
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.
DNNL can be used outside of a Python context, so I'm afraid that won't work in all circumstances (this doesn't depend on numpy).
One can either rely on MKL being allowed in the unfree list (which allows this to work in both mkl and non-mkl situations), as is done here, or it could be enabled by a dedicated flag and require downstream libraries to opt-in.
It would be nice if Nix had a base environment configuration for these numerics, since generally you want consistent libraries across the whole of the stack rather approaching these on a per-library basis.
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.
One can either rely on MKL being allowed in the unfree list
I'M not sure what you mean by this. As far as I know in the current implementation nix would just always try to fulfill the MKL dependency, throwing an error when unfree packages are disabled. One could get around that by explicitly passing null
, but a proper switch would be nicer.
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.
@timokau is right: a quick test demonstrates that this will fail to build if you don't have the unfree packages enabled. Since callPackage
will fill in mkl
from all-packages.nix
, the default value inside dnnl/default.nix
has no effect.
An additional issue is that dnnl
's CMake build requires a non-default flag to use MKL: https://github.com/intel/mkl-dnn/blob/master/cmake/options.cmake#L157
This PR follows up on what's implemented here and fixes the above two issues:
#74893
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.
This has two issues (see above comment and follow-up PR which fixes them).
This commit continues the work proposed in NixOS#68014, and provides an entirely FOSS variant of the `dnnl` package. Updates to add an `mkl` flavor will be added later, pending discussion about the cleanest way to overlay this consistently. Fixes NixOS#67982, closes NixOS#68014 Co-authored-by: Alex Rice <alexrice999@hotmail.co.uk>
This commit continues the work proposed in #68014, and provides an entirely FOSS variant of the `dnnl` package. Updates to add an `mkl` flavor will be added later, pending discussion about the cleanest way to overlay this consistently. Fixes #67982, closes #68014 Co-authored-by: Alex Rice <alexrice999@hotmail.co.uk>
This commit continues the work proposed in NixOS#68014, and provides an entirely FOSS variant of the `dnnl` package. Updates to add an `mkl` flavor will be added later, pending discussion about the cleanest way to overlay this consistently. Fixes NixOS#67982, closes NixOS#68014 Co-authored-by: Alex Rice <alexrice999@hotmail.co.uk> (cherry picked from commit d411938)
Motivation for this change
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nix-review --run "nix-review wip"
./result/bin/
)nix path-info -S
before and after)fixes #67982
I can't get the tests to build atm here is the log
https://gist.github.com/alexarice/5fde03409d660638036d3a0b6fedf704