|
1 | 1 | # Getting started with Cog |
2 | 2 |
|
3 | | -First step is to start a server. You'll need to point it at a Docker registry to store the Docker images For example, [create one on Google Cloud Container Registry](https://cloud.google.com/container-registry/docs/quickstart). |
| 3 | +First step is to start a server. You'll need to point it at a Docker registry to store the Docker images For example, [create one on Google Cloud Container Registry](https://cloud.google.com/container-registry/docs/quickstart). |
4 | 4 |
|
5 | 5 | Then, start the server, pointing at your Docker registry: |
6 | 6 |
|
7 | 7 | cog server --port=8080 --docker-registry=gcr.io/some-project/cog |
8 | 8 |
|
9 | | - |
10 | 9 | Next, let's build a model. We have [some models you can play around with](https://github.com/replicate/cog-examples). Clone that repository (you'll need git-lfs) and hook up that directory to your Cog server: |
11 | 10 |
|
12 | 11 | cd example-models/inst-colorization/ |
13 | 12 | cog repo set localhost:8080/examples/inst-colorization |
14 | 13 |
|
15 | | -Then, let's build it: |
| 14 | +Take a look at `cog.yaml` and `model.py` to see what we're building. |
| 15 | + |
| 16 | +Then, let's push it: |
| 17 | + |
| 18 | + cog push |
16 | 19 |
|
17 | | - cog build |
| 20 | +This has uploaded the currently directory to the server and the server has stored that as a version of your model. In the background, it is now building two Docker images (CPU and GPU variants) that will run your model. You can see the status of this build with `cog show`, replacing the ID with your model's ID: |
18 | 21 |
|
19 | | -This will take a few minutes. In the meantime take a look at `cog.yaml` and `model.py` to see what we're building. |
| 22 | + $ cog show b31f9f72d8f14f0eacc5452e85b05c957b9a8ed9 |
| 23 | + ... |
| 24 | + CPU image: Building. Run `cog build logs 8f3a05c42ee5` to see its progress. |
| 25 | + GPU image: Building. Run `cog build logs b087a0bb5b7a` to see its progress. |
20 | 26 |
|
21 | | -When that has finished, you can run inferences on the built model from any machine that is pointed at the server. Replace the ID with your model's ID, and the file with an image on your disk you want to colorize: |
| 27 | +When the build has finished, you can run inferences on the built model from any machine that is pointed at the server. Replace the ID with your model's ID, and the file with an image on your disk you want to colorize: |
22 | 28 |
|
23 | 29 | cog infer b31f9f72d8f14f0eacc5452e85b05c957b9a8ed9 -i @hotdog.jpg |
24 | 30 |
|
25 | 31 | You can also list the models for this repo: |
26 | 32 |
|
27 | 33 | cog list |
28 | 34 |
|
29 | | -You can see more details about the model: |
| 35 | +## Deploying the model |
| 36 | + |
| 37 | +Cog builds Docker images for each version of your model. Those Docker images serve an HTTP inference API (to be documented). |
| 38 | + |
| 39 | +To get the Docker image, run this with the version you want to deploy: |
30 | 40 |
|
31 | 41 | cog show b31f9f72d8f14f0eacc5452e85b05c957b9a8ed9 |
32 | 42 |
|
33 | | -In this output is the Docker image. You can run this anywhere a Docker image runs to deploy your model. For example: |
| 43 | +In this output is the name of the CPU or GPU Docker images, dependending on whether you are deploying on CPU or GPU. You can run these anywhere a Docker image runs. For example: |
34 | 44 |
|
35 | | - $ docker run -d -p 8000:8000 --gpus all registry.hooli.net/colorization:b6a2f8a2d2ff-gpu |
36 | | - $ curl http://localhost:8000/infer -F [email protected] |
| 45 | + $ docker run -d -p 5000:5000 --gpus all registry.hooli.net/colorization:b6a2f8a2d2ff-gpu |
| 46 | + $ curl http://localhost:5000/infer -F [email protected] |
0 commit comments