Skip to content
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

Support CUDA in WSL2 #44

Closed
wants to merge 8 commits into from
Closed

Support CUDA in WSL2 #44

wants to merge 8 commits into from

Conversation

Atry
Copy link

@Atry Atry commented Feb 11, 2023

/usr/lib/wsl/lib includes CUDA drivers for WSL2, which should be exposed to the FHS environment in order to use CUDA.

Note that both this PR and nix-community/NixOS-WSL#221 are required in order to enable CUDA in WSL2 in the VS Code Terminal

extraBuildCommands = ''
if [[ -d /usr/lib/wsl ]]
then
cp -rsHf /usr/lib/wsl usr/lib/wsl
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we symlink?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cp -rsHf is already symlinking.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Atry Thanks for clarifying, I wasn't aware it was symlinking either. I will keep it as it is then in PR #47, but I will add a comment about it actually symlinking for clarify sake.

@msteen
Copy link
Collaborator

msteen commented Feb 14, 2023

Closed in favor of #47.

@msteen msteen closed this Feb 14, 2023
@soleera
Copy link

soleera commented Feb 16, 2023

Won't these symlinks just become self-referential once the FHS environment is created? Hard links are a no-go as well since wsl/libs and wsl/drivers are actually mount points to a different filesystem... I think the only way to avoid making a full copy would be if we could prevent /usr/lib/wsl from being unshared by bwrap in the first place...

@Atry Atry deleted the patch-1 branch February 16, 2023 20:16
@soleera
Copy link

soleera commented Feb 22, 2023

So I managed to get this working by overriding buildFHSUserEnvBubblewrap with an overlay in my flake.nix:

(self: super: {
  buildFHSUserEnvBubblewrap = {...}@args: super.buildFHSUserEnvBubblewrap (args // {
    extraBwrapArgs = [ "--tmpfs /wsl" "--ro-bind /usr/lib/wsl /wsl" ];
    extraBuildCommands = "ln -s /wsl $out/usr/lib/wsl";
  });
})

probably best for this sort of thing to added to buildFHSUserEnvBubblewrap itself rather than being re-implemented in every package that uses it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants