Hello,
I’m new to nix and I’m trying to set up a pytorch development environment using a nix flake. Here’s the flake:
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/24.05";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
in {
devShell = with pkgs; mkShell {
packages = [
python310
];
env = {
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [ pkgs.stdenv.cc.cc ];
};
};
}
);
}
And the following is my requirements.txt:
--extra-index-url https://download.pytorch.org/whl/cu121
torch==2.5.1+cu121
numpy
When enter the dev shell and create (via python3 -m venv .venv
) and activate venv and install the packages from the requirements file and test for cuda support (via torch.cuda.is_available()
), the test returns False. However, if i don’t enter the dev shell (basically not use the flake) and set everything up via system’s python, cuda is available.
Before using requirements.txt I tried with poetry and poetry2nix, and ran into the same issue. I’m not entirely sure whats going on here. Am I missing something?