Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Cuda 10.1 /Cuda 10.2 related torch package installation issue in Docker. #642

Merged
merged 12 commits into from
Nov 19, 2020
14 changes: 9 additions & 5 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
ARG BASE_IMAGE=ubuntu:18.04

FROM ${BASE_IMAGE} AS compile-image

ARG BASE_IMAGE=ubuntu:18.04
harshbafna marked this conversation as resolved.
Show resolved Hide resolved
ENV PYTHONUNBUFFERED TRUE

RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \
Expand All @@ -41,13 +41,17 @@ RUN python3 -m venv /home/venv

ENV PATH="/home/venv/bin:$PATH"

RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
RUN update-alternatives --install /usr/local/bin/pip pip /usr/local/bin/pip3 1
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1 \
&& update-alternatives --install /usr/local/bin/pip pip /usr/local/bin/pip3 1

# This is only useful for cuda env
# This is only useful for cuda env
RUN export USE_CUDA=1

RUN pip install --no-cache-dir torch torchvision torchtext torchserve torch-model-archiver
RUN if [ "$BASE_IMAGE" != "${BASE_IMAGE#*cuda:10.1}" ]; then \
pip install --no-cache-dir torch==1.6.0+cu101 torchvision==0.7.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html; \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@harshbafna Shouldn't this be in the else part based on the check?

Also please have the torchvision + cuda version a variable so that we don't have to keep changing the Dockerfile with each release

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@harshbafna Any update on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chauhang: This has been taken care of. @jeremiahschung has implemented these changes. Could you please review it once again?

else \
pip install --no-cache-dir torch torchvision torchtext torchserve torch-model-archiver; \
fi
harshbafna marked this conversation as resolved.
Show resolved Hide resolved

# Final image for production
FROM ${BASE_IMAGE} AS runtime-image
Expand Down
9 changes: 8 additions & 1 deletion docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ For creating CPU based image :
DOCKER_BUILDKIT=1 docker build --file Dockerfile -t torchserve:latest .
```

For creating GPU based image :
For creating GPU based image with Cuda 10.2 :
harshbafna marked this conversation as resolved.
Show resolved Hide resolved

```bash
DOCKER_BUILDKIT=1 docker build --file Dockerfile --build-arg BASE_IMAGE=nvidia/cuda:10.2-cudnn7-runtime-ubuntu18.04 -t torchserve:latest .
```

For creating GPU based image with Cuda 10.1 :
harshbafna marked this conversation as resolved.
Show resolved Hide resolved

```bash
DOCKER_BUILDKIT=1 docker build --file Dockerfile --build-arg BASE_IMAGE=nvidia/cuda:10.1-cudnn7-runtime-ubuntu18.04 -t torchserve:latest .
harshbafna marked this conversation as resolved.
Show resolved Hide resolved
```
Expand Down