Docker build ERROR: Could not find a version that satisfies the requirement torch==1.5.1

2.7k views Asked by At

I have a Dockerfile that has the following format:

FROM python:latest
ADD requirements.txt .
RUN pip3 install -r requirements.txt
CMD ["python", "script.py"]

Where my requirements.txt looks like:

grpcio==1.31.0
grpcio-tools==1.31.0
torch==1.5.1

When I execute docker image build . I get the following error:

Sending build context to Docker daemon  61.44kB
Step 1/7 : FROM python:latest
 ---> dfc47c6cee13
Step 2/7 : ADD requirements.txt .
 ---> Using cache
 ---> 3be914d5b849
Step 3/7 : RUN pip3 install -r requirements.txt
 ---> Running in 372c329c76fa
Collecting grpcio==1.31.0
  Downloading grpcio-1.31.0.tar.gz (20.0 MB)
Collecting grpcio-tools==1.31.0
  Downloading grpcio-tools-1.31.0.tar.gz (2.1 MB)
ERROR: Could not find a version that satisfies the requirement torch==1.5.1 (from -r requirements.txt (line 3)) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2)
ERROR: No matching distribution found for torch==1.5.1 (from -r requirements.txt (line 3))
The command '/bin/sh -c pip3 install -r requirements.txt' returned a non-zero code: 1

This was a strange error to receive because if I recall correctly, torch was able to be installed fairly recently (as early as 2 weeks ago), so I'm not sure why this is happening.

1

There are 1 answers

0
Christopher Settles On

I solved this by changing the version in the Dockerfile by instead of doing

FROM python:latest

changing it to

FROM python:3.7.4

I suppose that torch has an issue with installing python3.9.0, which is what python:latest was updated to a couple days ago. Better to force the docker container to work with a specific known version :)