Trying to use pytorch in python environment with poetry2nix

I’ll preface by saying that I coded mostly in academia, and this is my first foray into trying to write a proper python package. I know how to code in python as in I can script a data analysis pipeline, but I know very little in terms of organizing a package.

I’m trying to develope a python project, and trying to do it by using poetry and poetry2nix. I will be using pytorch for this project, but can’t figure out how to make poetry get the proper pytorch and get it working in my environment. Here is my repo if anyone wants to check out my pyproject.toml and flake.nix

The error I’m getting is when I run python in my dev environment, importing torch gives a library error. I do have nix-ld on my system configuration. Not sure if I should be trying to add libraries to nix-ld on my system config, or should be adding some packages to the flake.nix so that nix develop finds it.

The error I’m getting is the following;

$ nix develop .#poetry
$ poetry run python
>>> import torch
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/batuhan/.cache/pypoetry/virtualenvs/radix-addition-mYzO7gsu-py3.11/lib/python3.11/site-packages/torch/", line 239, in <module>
    from torch._C import * # noqa: F403
ImportError: cannot open shared object file: No such file or directory

I’m 100% sure I’m supposed to install pytorch some other way into my environment, but can’t figure out how I should be doing this. If anyone has any specific instructions, I appreciate it. I’m trying to figure out how to solve this problem by further reading on poetry2nix readme and documentation, along with nix pills; but in the meantime if anyone can help that would be awesome.