Torch cpu as a dependency of package

Hi, I have a trained model and created a Django app to host this model. Everything works great in development but now as I am trying to package the Django app for production I have the problem that setuptools can’t seem to install pytorch correctly. In my setup.py I have install_requires containing "torch==1.2.0+cpu", "torchvision==0.4.0+cpu and the dependency_links containing https://download.pytorch.org/whl/torch_stable.html.

This seems to be finding torch on pip instead and deciding it can’t install.

I have also tried with install_requires containing

"torch==1.2.0",
"torchvision=0.4.0",

and dependency_links containing

https://download.pytorch.org/whl/cpu/torch_stable.html

Neither of these seem to work and I can’t find anything online about this issue. Has anyone done this before and how did you do it?

1 Like

I’ve had some success using URL dependency syntax from PEP 508. I had to commit to a specific python version and architecture, though. It’s fine in my case, I know the environment where the package will be used. I’ve looked for a way to leave out the environment spec, but haven’t found anything.

Example entry in install_requires: "torch @ https://download.pytorch.org/whl/cpu/torch-1.3.1%2Bcpu-cp36-cp36m-linux_x86_64.whl"

The links can be found here: https://download.pytorch.org/whl/torch_stable.html.