NixOS-WSL
NixOS-WSL copied to clipboard
fix: set wsl.useWindowsDriver when the nvidia-ctk is enabled
This improves the user experience as whenever the user enables the config.hardware.nvidia-container-toolkit.enable option, they cannot use their Nvidia GPU's within the Docker containers because of missing libraries.
This gets fixed by setting wsl.useWindowsDriver explicitly when the user requests to enable GPU support on Docker containers.
Issue and fix provided by @qwqawawow
Related: https://github.com/nix-community/NixOS-WSL/issues/433 Related: https://github.com/NVIDIA/nvidia-container-toolkit/issues/452
Note: unsure if this is the right approach for this project. I am the maintainer of the CDI-generation for NixOS, and we got a couple of reports that users could not use their GPU's inside Docker containers.
I cannot test it since I don't use NixOS-WSL, but I thought it would be good to improve the user experience here a bit if possible.
Thanks :)
I just tested this following https://github.com/NixOS/nixpkgs/pull/312253 and can confirm it works fine with config.hardware.nvidia-container-toolkit.enable.
However, I don't think this should be limited only to wsl.docker-desktop.enable, since Podman users, for example, may want this feature by default without having to install Docker on their system.
Thanks a lot for checking @loicreynier! Good point, I have updated the PR to take into account config.virtualisation.podman.enable and config.virtualisation.docker.enable if the docker package supports CDI (Docker >= 25).
Looks good to me! Tested on a Podman setup and works as expected.
Can this be force-pushed ?
Excuse me, should the file nvidia-container-toolkit.json partly depend on NixOS's nvidia driver? nvidia-x11-555.58-6.6.36
Here is
{
"containerPath": "/usr/bin/nvidia-smi",
"hostPath": "**/nix/store/5s8mapl88avcqrggazg5kvm1y6b36a5p-nvidia-x11-555.58-6.6.36-bin/bin/nvidia-smi**",
"options": [
"ro",
"nosuid",
"nodev",
"bind"
]
},
{
"containerPath": "/usr/local/nvidia/lib",
"hostPath": "/**nix/store/qb18b5vz3rd6jch2klqfkr9zv9pxnj06-nvidia-x11-555.58-6.6.36/lib**",
"options": [
"ro",
"nosuid",
"nodev",
"bind"
]
},
{
"containerPath": "/usr/local/nvidia/lib64",
"hostPath": "/nix/store/qb18b5vz3rd6jch2klqfkr9zv9pxnj06-nvidia-x11-555.58-6.6.36/lib",
"options": [
"ro",
"nosuid",
"nodev",
"bind"
]
}
Excuse me, should the file nvidia-container-toolkit.json partly depend on NixOS's nvidia driver?
Yes. This is expected.