Coder Social home page Coder Social logo

Comments (5)

entrpn avatar entrpn commented on June 22, 2024 9

If anyone needs this, I did it as follows:

FROM nvidia/cuda:11.0.3-cudnn8-runtime-ubuntu18.04

RUN apt-get update
RUN apt-get install software-properties-common -y
RUN add-apt-repository ppa:deadsnakes/ppa -y
RUN apt-get install python3.8 -y
RUN apt-get install python3.8-distutils -y

RUN apt-get install python-dev python3-dev python3.8-dev \
     build-essential libssl-dev libffi-dev \
     libxml2-dev libxslt1-dev zlib1g-dev -y

RUN apt-get update && \
    apt-get install -y --no-install-recommends gcc

RUN apt-get install curl wget -y

RUN apt-get install linux-libc-dev -y

RUN apt-get install libc6-dev -y

RUN wget https://bootstrap.pypa.io/get-pip.py
RUN  python3.8 get-pip.py

ENV APP_HOME=/app

WORKDIR $APP_HOME

COPY . /app

RUN pip3.8 install --no-cache-dir -r requirements.txt

EXPOSE 80

CMD ["gunicorn","main:app","-w","1","--threads", "1", "--timeout", "1500", \
  "--worker-connections=300","-k","uvicorn.workers.UvicornWorker","--bind", "0.0.0.0:80"]

My requirements.txt:

tensorflow
tensorflow-hub
matplotlib
six
pillow
notebook
pydantic
fastapi
uvicorn[standard]
gunicorn

Probably don't need the notebook there. Also the big timeout time is due to me loading this in my laptop that doesn't have cuda installed so the model takes forever to load and I need to increase the timeout for testing. on a GPU you wouldn't need it.

from uvicorn-gunicorn-fastapi-docker.

tiangolo avatar tiangolo commented on June 22, 2024 4

Hmm, not really, everything runs on the CPU and only very specific custom and complex code would run on GPU.

To make something run on GPU you would use something like a deep learning framework like PyTorch or a tool to perform Numpy-like operations in GPU, like https://cupy.chainer.org/. But it would be only for Numpy-like operations. Linear algebra stuff in big matrices and vectors, that's what GPUs can do very well.

But the rest of the API code would still run in CPU.

Now, to use nvidia-docker you might want to look at https://github.com/tiangolo/uvicorn-gunicorn-machine-learning-docker

I haven't been able to update it in a while but might still help you a bit.

from uvicorn-gunicorn-fastapi-docker.

GitVHV avatar GitVHV commented on June 22, 2024 2

When my number of workers is 2, there is a CUDA GPUS error while I want to use workers for 1 GPU. Can someone help me please
image
image

from uvicorn-gunicorn-fastapi-docker.

Shane-Neeley avatar Shane-Neeley commented on June 22, 2024 1

Thanks for the response. I eventually got a system working with nvidia-docker and flask. I wasn't aware of that ML repo you made. I'll check that out for my next project.

from uvicorn-gunicorn-fastapi-docker.

github-actions avatar github-actions commented on June 22, 2024

Assuming the original issue was solved, it will be automatically closed now. But feel free to add more comments or create new issues.

from uvicorn-gunicorn-fastapi-docker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.