Coder Social home page Coder Social logo

servingmlfastcelery's Introduction

ServingMLFastCelery

Working example for serving a ML model using FastAPI and Celery.

Usage

Install requirements:

pip install -r requirements.txt

Set environment variables:

  • MODEL_PATH: Path to pickled machine learning model
  • BROKER_URI: Message broker to be used by Celery e.g. RabbitMQ
  • BACKEND_URI: Celery backend e.g. Redis
export MODEL_PATH=...
export BROKER_URI=...
export BACKEND_URI=...

Start API:

uvicorn app:app

Start worker node:

celery -A celery_task_app:worker worker -l info

servingmlfastcelery's People

Contributors

jonathanreadshaw avatar

Stargazers

Florian Wolpert avatar Punitvara avatar Akash Sonowal avatar Mohammed Mehdi avatar Tom Mery avatar A Tiwari avatar Max avatar  avatar Grigory Kozhanov avatar Kei avatar Badri avatar Leonardo Marinho de Melo Júnior avatar Nguyen Van Thanh avatar  avatar Ramazan GUVEN avatar Артем Васин avatar Nelson Guamán avatar  avatar Malcolm Jones (bossjones/Tony Dark) avatar Alex avatar Faris Hijazi avatar  avatar  avatar Oliver Kurrle avatar  avatar Patrick avatar Nguyễn Thái Học avatar Maryam Saeedi avatar Nguyễn Tiến Đồng avatar Dmitrii I avatar Naresh Kumar avatar Jaemin Noh avatar baudneo avatar Babafemi Sorinolu avatar nagibator_archivator avatar asdas12312weq avatar Michael Paccione avatar Ta Ko avatar steve avatar Aditya Rachman Putra avatar Muhammad Ali avatar Zakhar Kogan avatar Andrew Duggan avatar  avatar Nonpavit Detbun avatar  avatar Naum Rusomarov avatar Nikita avatar Felipe Whitaker avatar  avatar Vladislav avatar Nitin Chaudhary avatar socar-humphrey avatar Hyeonji_Kim avatar David GF avatar Kevin Zezel Gomes avatar The Dude avatar NachoAz avatar Fasetire Gbolahan avatar Billie avatar  avatar insightous avatar  avatar Andrea Guzzo avatar Andreas Motl avatar Robin Cole avatar Pawel Kranzberg avatar Kyle Dunovan avatar  avatar Robert Potter avatar Michel SEBAG avatar

Watchers

subhrajit mohanty avatar  avatar

servingmlfastcelery's Issues

dockerize the program

Thanks for sharing , really love the article on medium.
How does the cellery and worker being implemented ?on dedicated docker? separated ?
can u please consider share the dockrized version of it - it would be really helpful getting the whole idea of setup.

How to instantiate one single model instance shared by all threads

Thank you for this insightful example to host ML model via Celery and FastAPI. In your blog, you mentioned that "There will be a PredictTask object for each worker process. Therefore if a worker has four threads then the model will be loaded four times (each is then stored in memory as well". This is exactly my concern. I think each thread would try to instantiate its own model instance, but if the model is really expensive or some states need be shared by the calling threads, then we want only one single model instance shared by all threads, but how could we do it properly? Any suggestion?

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.