-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
nixos/nvidia-container-toolkit: add option for driver path #312253
nixos/nvidia-container-toolkit: add option for driver path #312253
Conversation
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 @loicreynier, trying to understand a bit here, since I'm not familiar with WSL myself.
We had a related case at nix-community/NixOS-WSL#433; how is it different from this, does enabling wsl.useWindowsDriver
work for you? Or is this PR needed even in that case?
type = with lib.types; nullOr path; | ||
default = null; | ||
description = '' | ||
Custom NVidia driver path for systems not using NixOS to setup NVidia drivers. |
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.
Custom NVidia driver path for systems not using NixOS to setup NVidia drivers. | |
Custom Nvidia driver path for systems not using NixOS to setup Nvidia drivers. |
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.
Just to be consistent with current casing.
@@ -17,11 +17,14 @@ | |||
(mount: | |||
["${lib.getExe jq} '${jqAddMountExpression} ${builtins.toJSON (mkMount mount)}'"]) | |||
mounts; | |||
ldLibraryPathExport = if builtins.isString nvidia-driver then "export LD_LIBRARY_PATH=${nvidia-driver}/lib" else ""; |
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.
Why this behavior only when the provided path is a string? Please explain a little further how this new attribute might be used.
I would like to avoid surprises when nvidia-driver
is something other than null
and a string, we will silently fallback to not use the provided parameter. Is there any chance for the user to have provided a nix path?
Also, can we use a flag of nvidia-ctk cdi generate
rather than using an envvar? I see --driver-root
; others might be relevant too. I think this is more explicit and lets less room for unexpected behaviors.
Thanks for pointing out nix-community/NixOS-WSL#433. I wasn't aware that NixOS WSL had this Linking the Window driver files (as done by this option) is probably a better approach than what I proposed here. I don't think this PR is needed anymore. For reference, I couldn't make it work (without the above mentioned option) using the nvidia-ctk --debug cdi generate \
--discovery-mode wsl \
--driver-root /usr/lib/wsl/lib/ \
--library-search-path /usr/lib/wsl/lib/ Output
|
I cannot help but think that there must be something we can do (at the NixOS-WSL level) to improve this user experience. If:
Then, we can set
Thanks for the input. |
I think it would be reasonable since, as far as I know, the easiest way to make it work is to implement something similar to what this option does. Additionally, I think it is worth noting that since WSL aims to simplify the interaction between Linux and the Windows host as much as possible, we should avoid duplicates and rely solely on the native drivers. |
Thank you, I have created nix-community/NixOS-WSL#478. Let me know if that looks fine or if you think it can be improved somehow.
I might be missing here a bit, sorry. With this comment you mean that you encourage to use the |
This one can be probably closed. Thank you @loicreynier for the contribution and for following up on this. |
Yes exactly this is what I meant, sorry for the unclear comment. |
Description of changes
Add an option
nvidia-driver-path
(inhardware.nvidia-container-toolkit
) for systems where NVIDIA drivers are not set up by NixOS. This is useful for example in WSL systems where the Windows drivers can be used and are located in/usr/lib/wsl/lib
.Tested with Podman
on a WSL NixOS system with
Also tested the compilation and run of simple CUDA programs on that container.
Not sure yet if this option should always disables the
mount-nvidia-executables
andmount-nvidia-docker-1-directories
options.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.