'Docker: can't install torch

Dockerfile:

FROM cityflowproject/cityflow

WORKDIR /usr/TrafficMannager

RUN apt-get update && apt-get upgrade -y && apt-get clean

RUN pip install --upgrade pip
RUN pip install torch


COPY . .

CMD chmod u+x scripts/container_instructions.sh;\
    ./scripts/container_instructions.sh pythonfile='main.py' model="DefaultModel" step=10 epochs=10

When the docker create the container it fails in pip install torch

I've worked on a project where those line & docker filed worked. All of the sudden, it's stopped working. (maybe problem with docker demon)

Edit(error):

 > [5/6] RUN pip install torch:                                                                                      
#8 3.464 Collecting torch                                                                                            
#8 3.896   Downloading torch-1.10.2-cp36-cp36m-manylinux1_x86_64.whl (881.9 MB)
#8 114.5 Killed
------
executor failed running [/bin/sh -c pip install torch]: exit code: 137


Solution 1:[1]

Did you try to increase the timeout for pip. with something like below:

pip install --default-timeout=900 torch

I had a similar issue and increased the timeout to allow enough time for installation of torch.

Got the inspiration from: error "socket.timeout: The read operation timed out" while installing a python module

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 lagyamfi