0

I created a python based web app (using flask and gunicorn) that contains a pytorch based library which can detect if the machine has CUDA GPUs. I added this image to azure container registry then used an azure container instance with GPU capabilities to deploy it. However when checking the logs, it tells me that it was not able to detect GPUs. What am I doing wrong here?

The Dockerfile used to create the image doesn't specify anything related to GPUs. is that the main problem?

I created my application on windows(which does not have gpu capabilities) but have been using wsl2 with ubuntu linux kernel to build the image

amro_ghoneim
  • 495
  • 1
  • 4
  • 14
  • 1
    hi @amro, as you started following up this same question through MS Q&A platform. and posting the Q&A Link here to help the other community members [check here](https://learn.microsoft.com/en-us/answers/questions/555113/how-to-run-docker-image-on-gpu-enabled-azure-conta.html) – Delliganesh Sevanesan Sep 17 '21 at 10:34

1 Answers1

0

So the main problem was with the Dockerfile indeed.

The GPU-enabled azure container instance documentation specifies a certain base image to be used

I was able to combine what I already had in the Dockerfile along with this base image to build my final image as such:

FROM python:3.7.8-slim as build
COPY requirements/common.txt requirements/common.txt
RUN apt-get update && apt-get install -y build-essential
RUN apt-get install -y cmake
RUN pip install -U pip && pip install -r requirements/common.txt

COPY ./api /app/api
COPY ./bin /app/bin
COPY wsgi.py /app/wsgi.py
COPY ./models /app/models

FROM nvidia/cuda:9.0-base-ubuntu16.04
COPY --from=build / /
COPY --from=build /app/wsgi.py /wsgi.py

WORKDIR /app
EXPOSE 8080
ENTRYPOINT ["bash", "/app/bin/run.sh"] 

I am not sure however if this is a production level acceptable solution but it was the only way I found that worked.

amro_ghoneim
  • 495
  • 1
  • 4
  • 14