Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No matching distribution found for torch==1.5.0+cpu on Heroku

I am trying to deploy my Django app which uses a machine learning model. And the machine learning model requires pytorch to execute. When i am trying to deploy it is giving me this error

ERROR: Could not find a version that satisfies the requirement torch==1.5.0+cpu (from -r /tmp/build_4518392d43f43bc52f067241a9661c92/requirements.txt (line 23)) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2, 0.4.1, 0.4.1.post2, 1.0.0, 1.0.1, 1.0.1.post2, 1.1.0, 1.2.0, 1.3.0, 1.3.1, 1.4.0, 1.5.0)
       ERROR: No matching distribution found for torch==1.5.0+cpu (from -r /tmp/build_4518392d43f43bc52f067241a9661c92/requirements.txt (line 23))
 !     Push rejected, failed to compile Python app.
 !     Push failed

My requirements.txt is

asgiref==3.2.7
certifi==2020.4.5.1
chardet==3.0.4
cycler==0.10.0
dj-database-url==0.5.0
Django==3.0.6
django-heroku==0.3.1
future==0.18.2
gunicorn==20.0.4
idna==2.9
imageio==2.8.0
kiwisolver==1.2.0
matplotlib==3.2.1
numpy==1.18.4
Pillow==7.1.2
psycopg2==2.8.5
pyparsing==2.4.7
python-dateutil==2.8.1
pytz==2020.1
requests==2.23.0
six==1.14.0
sqlparse==0.3.1
torch==1.5.0+cpu
torchvision==0.6.0+cpu
urllib3==1.25.9
whitenoise==5.0.1

And runtime.txt is python-3.7.5
However installing it on my computer is not giving any type of error when i use command pip install torch==1.5.0+cpu I am using python 3.7.5 and pip 20.0.2.
Complete code is here.
How to solve this issue i really need to deploy my app. Thanks

like image 407
Abhishek Pratap Singh Avatar asked May 16 '20 18:05

Abhishek Pratap Singh


1 Answers

PyTorch does not distribute the CPU only versions over PyPI. They are only available through their custom registry.

If you select the CPU only version on PyTorch - Get Started Locally you get the following instructions:

pip install torch==1.5.0+cpu torchvision==0.6.0+cpu -f https://download.pytorch.org/whl/torch_stable.html

Since you're not manually executing the pip install, you cannot simply add the -f https://download.pytorch.org/whl/torch_stable.html.

As an alternative, you can put it into your requirements.txt as a standalone line. It shouldn't really matter where exactly you put it, but it is commonly put at the very top.

-f https://download.pytorch.org/whl/torch_stable.html
asgiref==3.2.7
certifi==2020.4.5.1
chardet==3.0.4
cycler==0.10.0
dj-database-url==0.5.0
Django==3.0.6
django-heroku==0.3.1
future==0.18.2
gunicorn==20.0.4
idna==2.9
imageio==2.8.0
kiwisolver==1.2.0
matplotlib==3.2.1
numpy==1.18.4
Pillow==7.1.2
psycopg2==2.8.5
pyparsing==2.4.7
python-dateutil==2.8.1
pytz==2020.1
requests==2.23.0
six==1.14.0
sqlparse==0.3.1
torch==1.5.0+cpu
torchvision==0.6.0+cpu
urllib3==1.25.9
whitenoise==5.0.1
like image 159
Michael Jungo Avatar answered Oct 05 '22 23:10

Michael Jungo