GithubHelp home page GithubHelp logo

neverstopforever / cog-redis-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from replicate/cog-redis-example

0.0 0.0 0.0 9 KB

Docker Compose setup for running a Cog model with the built-in Redis worker

License: Apache License 2.0

cog-redis-example's Introduction

Cog Redis worker example

Docker Compose setup for running a Cog model with the built-in Redis worker, to emulate how the model is deployed on replicate.com, and to provide an end-to-end example of the Redis worker API.

You can use this project to debug the rare case where a model works locally but doesn't work on replicate.com, even though the development environment is the same as on replicate.com (11G RAM, T4 GPU).

Usage

First, start the docker-compose processes, specifying the model image you want to test:

$ IMAGE=r8.im/replicate/hello-world@sha256:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa docker compose up

In another shell, connect to Redis:

$ docker exec -it cog-redis redis-cli

Now you can queue up inputs in the format the model expects, e.g.

XADD input-queue * value '{"input": {"text": "world"}, "response_queue":"output-queue"}'

Shortly thereafter, outputs should be available on the output queue:

$ RPOP output-queue
"{\"status\": \"succeeded\", \"output\": \"hello world\", \"logs\": []}"

Use during development

If you want to test the Redis worker during development, copy the file docker-compose.yml into your project's root directory.

Build the Cog model:

$ cog build
[...]
Successfully built cog-my-model

Save the image name to your clipboard (in this example it's cog-my-model).

Then you can start docker-compose:

$ IMAGE=cog-my-model docker-compose up

And now you can push messages to the queue as in the previous section.

Use without GPU

By default the docker-compose file runs the model with GPU. If you don't have a GPU or don't need that, comment out the following lines from docker-compose.yml:

    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 1
              capabilities: [gpu]

cog-redis-example's People

Contributors

neverstopforever avatar andreasjansson avatar bfirsh 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.