Skip to content
Advertisement

How can I get torch-geometric to work using Nix?

I am trying to get the Python package torch-geometric to work using Nix (I am on NixOS). Currently, I use mach-nix to try and setup a Python environment. However, the difficulty is that some of the dependencies should be downloaded from a separate file server (not pypi), i.e. https://pytorch-geometric.com/whl/torch-1.8.0+cpu.html. I am first trying to setup an environment containing a single torch-geometric dependency: torch-sparse.

Currently I have the following shell.nix:

JavaScript

Which, upon running nix-shell, fails with the following error message:

JavaScript

I tried adding the which package to either checkInputs and buildInputs, but that does not solve the problem. Evidently, I try to build the package directly from its GitHub repo, as I am unsure on how to reference a wheel package in mach-nix. I am relatively new to the NixOS environment, and, quite frankly, I am completely lost.

How should I go about installing a Python package such as torch-sparse or torch-geometric? Am I even using the correct tools?

Advertisement

Answer

I have managed to come up with a working Nix expression. I will leave the answer here for future reference. Running the following expression using nix-shell will create a shell with torch-1.8.0 and torch-geometric-1.7.0 and their required dependencies.

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement