Hi, I only switched to nix recently and I’ve been attempting to setup an environment where I can do development in pytorch. I found some previous threads on the subject here, but none of them seemed to have a full example of a flake that you can nix develop and with my limited skills I haven’t yet been able to patch together something that works. I would strongly prefer to use the cuda-maintainers cachix where possible, as every time I have tried to compile torch it times out. I’d also prefer to do things the nix way wherever possible, but ultimately I just want something that will work. (And by work I mean something that at least lets you run the pytorch beginner example with cuda)
Here is the flake I have come up with so far:
{
description = "Pytorch development environment";
nixConfig = {
extra-substituters = [
"https://cuda-maintainers.cachix.org"
];
extra-trusted-public-keys = [
"cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E="
];
};
inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0";
outputs = {
self,
nixpkgs,
}: {
devShells.x86_64-linux.default = let
pkgs = import nixpkgs {
system = "x86_64-linux";
allowUnfree = true;
cudaSupport = true;
};
in
pkgs.mkShell {
packages = with pkgs; [
(python313.withPackages (p:
with p; [
# python packages
torchWithCuda
torchvision
]))
# non-python packages
];
};
};
}
This runs into the issue error: Package ‘cuda_nvcc-12.8.93’ in /nix/store/x06djk7jw02qb6y8fxd0mjgaksw2kd9n-source/pkgs/development/cuda-modules/generic-builders/manifest.nix:323 has an unfree license (‘CUDA EULA’), refusing to evaluate. Which is confusing to me since I already specify allowUnfree = true; in the nixpkgs config. Is the config somehow not visible? Any help would be appreciated.