Skip to content

feat: add nix flake#2

Open
drbh wants to merge 2 commits intoNVlabs:mainfrom
drbh:add-nix-flake
Open

feat: add nix flake#2
drbh wants to merge 2 commits intoNVlabs:mainfrom
drbh:add-nix-flake

Conversation

@drbh
Copy link
Copy Markdown
Contributor

@drbh drbh commented Mar 15, 2026

This PR adds nix flake to ease running this repo. The flake pulls CUDA 13.2, LLVM 21 with MLIR and Rust nightly 2025-07-16.

You can drop into the development shell via

nix develop

or run commands in the dev shell directly like

nix develop -c cargo test
# ...
# test result: ok. 0 passed; 0 failed; 49 ignored; 0 measured; 0 filtered out; finished in 0.00s

or

nix develop -c cargo run -p cutile-examples --example add_basic
# ...
#         2.0,
#         2.0,
#         2.0,
#         2.0,
#     ],
# )

@cryos
Copy link
Copy Markdown
Collaborator

cryos commented Mar 23, 2026

This is something I have been wanting to look into for a while. On a local dev machine I have nix installed on an Arch Linux system where libcuda.so is in /usr/lib/. In a normal shell this can be found, but when running nix develop it is not found. Everything else appeared to look good, and I only saw a conditional for NixOS. What would be the expected way for a flake to make the system CUDA driver available? I see:

target/debug/examples/add_basic: error while loading shared libraries: libcuda.so.1: cannot open shared object file: No such file or directory

I also had to add experimental-features = nix-command flakes to my local config. I think it would be good to resolve the CUDA linking and add a small amount of documentation similar to what you have in the PR for people to get up and running.

@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot bot commented Mar 24, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@drbh
Copy link
Copy Markdown
Contributor Author

drbh commented Mar 24, 2026

Hey @cryos thanks for taking a look!

I just pushed some updates so the flake will automatically look for the driver in expected locations and should work on linux distros like Ubuntu and Arch out of the box. I also updated the readme with some short notes about using the flake and included a comment about experimental features.

also a bit more info on the driver issue, this is actually something we've run into with some other nix/cuda projects at huggingface and our local nix expert has a nice solution outlined here: https://danieldk.eu/Software/Nix/Nix-CUDA-on-non-NixOS-systems#solutions. essentially we symlink the required libraries to the directory that nix defaults to. However in this case I avoided this requirement since it simplifies the workflow and nix is only used to create a development environment so I don't think there are any downsides from this approach.

please let me know if you run into any issues with the updated flake, or if I should update the readme in any way. Thanks!

@cryos
Copy link
Copy Markdown
Collaborator

cryos commented Mar 25, 2026

Awesome, sorry hectic few days but I will try to take another look at this later today. Appreciate all of the details!

@drbh
Copy link
Copy Markdown
Contributor Author

drbh commented Mar 25, 2026

no worries at all, thanks for reviewing!

@cryos
Copy link
Copy Markdown
Collaborator

cryos commented Mar 25, 2026

This looks good, I see the temporary directory with symlinks, ldd shows the linker finding the driver there, but on running the example I get:

     Running `target/debug/examples/add_basic`
Err(
    Anyhow(
        "error: CUDA driver error: DriverError(301, \"file not found\")",
    ),
)

The instructions look great, I guess there is something missing (this is the 13.1 driver).

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.

2 participants