Giter VIP home page Giter VIP logo

deployolo's Introduction

Hi Chris,

I wanted to give you a quick rundown of deploying GPU APIs on paperspace. I think working backwards might be a reasonable way to walk through the code. To deploy this code:

git clone https://github.com/amarder/deployolo.git
cd deployolo
pspace deployment up -c paperspace.json

This sets up a few things:

  1. Autogenerated API Documentation: <endpoint>/docs

  2. NVIDIA-SMI output: <endpoint>/nvidia-smi/

    Underlying code: https://github.com/amarder/deployolo/blob/main/main.py#L37-L41

  3. TensorFlow physical devices: <endpoint>/devices/

    Underlying code: https://github.com/amarder/deployolo/blob/main/main.py#L43-L47

  4. YOLO predictions: <endpoint>/yolo/

    Underlying code: https://github.com/amarder/deployolo/blob/main/main.py#L10-L35

I use numbers 2 and 3 to make sure that paperspace is using the GPU. To get a YOLO prediction I post a jpeg file to the API using the requests package like so:

import requests
with open('image.jpg', 'rb') as f:
    response = requests.post('<endpoint>/yolo/', files={'file': f})

Things to keep in mind:

  1. We're deploying a public image.

  2. The base image we're using in our Dockerfile has GPU support: https://github.com/amarder/deployolo/blob/main/Dockerfile#L1

  3. These lines in the Dockerfile instantiate a YOLOV8Detector object, when we do this the first time the required models are downloaded from the internet. It's nice to put this in the Dockerfile so the model files are included in the docker image and don't need to be downloaded from the internet every time we spin up a copy of this image: https://github.com/amarder/deployolo/blob/main/Dockerfile#L10C25-L12

Let me know if you have any questions.

To run locally use:

docker compose up --build

This will automatically reload the code when it changes.

deployolo's People

Watchers

Andrew Marder avatar

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.