-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
mistral-rs: fix cuda support #343254
base: master
Are you sure you want to change the base?
mistral-rs: fix cuda support #343254
Conversation
bc57c89
to
2970b76
Compare
Result of 1 package built:
|
Result of 1 package built:
|
2970b76
to
a85c226
Compare
let | ||
patchelfCommand = binaryName: '' | ||
patchelf \ | ||
--add-rpath ${ |
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.
Can we use autoPatchelfHook
with runtimeDependencies
(Since there are only this two executables)?
https://nixos.org/manual/nixpkgs/unstable/#setup-hook-autopatchelfhook
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.
Thanks for the tip. I went and try it and it doesn't work weirdly...
I'm pushing the 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.
The ldd
output is the same, but I guess that the rpath
is not about that.
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.
a85c226
to
3eddcf9
Compare
runtimeDependencies = lib.optionals cudaSupport [ | ||
cudaPackages.libcublas | ||
cudaPackages.libcurand | ||
]; |
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.
runtimeDependencies = lib.optionals cudaSupport [ | |
cudaPackages.libcublas | |
cudaPackages.libcurand | |
]; |
Try this. I guess it's because autoPatchelfHook
overrides rpath (--set-rpath
) instead of prepending/appending (--add-rpath
) it.
nixpkgs/pkgs/build-support/setup-hooks/auto-patchelf.py
Lines 303 to 307 in 122d20b
if rpath: | |
print("setting RPATH to:", rpath_str) | |
subprocess.run( | |
["patchelf", "--set-rpath", rpath_str, path.as_posix()] + extra_args, | |
check=True) |
But you already have these two in buildInputs
, and it seems unneeded to add them to runtimeDependencies
again, see torch
as an example:
nixpkgs/pkgs/development/python-modules/torch/bin.nix
Lines 45 to 77 in 122d20b
nativeBuildInputs = lib.optionals stdenv.isLinux [ | |
addDriverRunpath | |
autoPatchelfHook | |
autoAddDriverRunpath | |
]; | |
buildInputs = lib.optionals stdenv.isLinux ( | |
with cudaPackages; | |
[ | |
# $out/${sitePackages}/nvfuser/_C*.so wants libnvToolsExt.so.1 but torch/lib only ships | |
# libnvToolsExt-$hash.so.1 | |
cuda_nvtx | |
cuda_cudart | |
cuda_cupti | |
cuda_nvrtc | |
cudnn | |
libcublas | |
libcufft | |
libcurand | |
libcusolver | |
libcusparse | |
nccl | |
] | |
); | |
autoPatchelfIgnoreMissingDeps = lib.optionals stdenv.isLinux [ | |
# This is the hardware-dependent userspace driver that comes from | |
# nvidia_x11 package. It must be deployed at runtime in | |
# /run/opengl-driver/lib or pointed at by LD_LIBRARY_PATH variable, rather | |
# than pinned in runpath | |
"libcuda.so.1" | |
]; |
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 guess we have to add something like extraRuntimeDependencies
to autoPatchelfHook
then.
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.
Also try this:
nixpkgs/pkgs/development/python-modules/torch/bin.nix
Lines 71 to 77 in 122d20b
autoPatchelfIgnoreMissingDeps = lib.optionals stdenv.isLinux [ | |
# This is the hardware-dependent userspace driver that comes from | |
# nvidia_x11 package. It must be deployed at runtime in | |
# /run/opengl-driver/lib or pointed at by LD_LIBRARY_PATH variable, rather | |
# than pinned in runpath | |
"libcuda.so.1" | |
]; |
I guess runtimeDependencies
is still not necessary, unless cuda libraries are loaded by dlopen
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.
Thank you for your suggestions !
I tried removing the
runtimeDependencies = lib.optionals cudaSupport [
cudaPackages.libcublas
cudaPackages.libcurand
];
block but it doesn't work better.
Those libs are loaded at runtime (dlopen
I guess) and thus are not seen as required by
patchelf`.
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 guess
runtimeDependencies
is still not necessary, unless cuda libraries are loaded by dlopen
This works for the cuda
lib but it still complains about cublas
...
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 guess we have to add something like extraRuntimeDependencies to autoPatchelfHook then.
appendRunpathsArray
exists, used for adding $ORIGIN
in a few places
@GaetanLepage Could you fix this to a usable state? I suppose it's at least better than nothing |
Sure. Maybe let's merge the update first and then I'll rebase this branch. |
Done |
3eddcf9
to
6c3b603
Compare
Currently fails to build with
|
Description of changes
cc @SomeoneSerge
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.