I use poetry and direnv. Coming from node/npm, it feels natural for me to just do this. I have really no troubles of installing Pytorch with poetry
[tool.poetry.dependencies]
python = ">=3.10,<3.12.0"
torch = {version = "^2.0.1+cu118", source = "torch118"}
torchvision = {version = "^0.15.2+cu118", source = "torch118"}
[[tool.poetry.source]]
name = "torch118"
url = "https://download.pytorch.org/whl/cu118"
priority = "explicit"
However, since CUDA 12.0 and Pytorch 2.1.0, just install like normal poetry add torch torchvisionHowever, this works perfectly with Poetry 1.8 and Pytorch 2.2. I suppose the only problem is what PDM also does, where the lock file is platform-dependent. I'm not sure whether Poetry allows you to select a specific lock file, however.
A notable open issue in poetry is we can't currently specify one dependency on torch, and have it grab CPU version on some systems and GPU on others. Does PDM solve that?