-
Notifications
You must be signed in to change notification settings - Fork 694
docs: document --use-cog-base-image and prebuilt base images #3088
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
anish-sahoo
wants to merge
9
commits into
main
Choose a base branch
from
issue-1820
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+251
−88
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
696e88d
docs: document --use-cog-base-image and prebuilt base images
anish-sahoo d71f744
docs: add link to available base image list
anish-sahoo e433b85
feat: add concurrent decorator
anish-sahoo 0b3f792
fix: bound concurrent max conversion
anish-sahoo bc66ab7
Update pkg/schema/python/parser_test.go
anish-sahoo 9d2c186
Merge branch 'pr-3089' into issue-1820
anish-sahoo e0e1b47
fix: remove duplicate function declaration in parser_test.go
anish-sahoo 4af3a18
revert: remove concurrency branch changes
anish-sahoo 27d4f6e
Merge branch 'main' into issue-1820
anish-sahoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # Base images | ||
|
|
||
| Cog builds your model into a Docker image. To speed up builds and reduce cold boot times, Cog uses **prebuilt base images** by default. These images contain the common dependencies that most models need, so Cog doesn't have to install them from scratch every time you build or push. | ||
|
|
||
| ## What is a Cog base image? | ||
|
|
||
| A Cog base image is a Docker image maintained by Replicate that includes: | ||
|
|
||
| - **Python runtime** — the Python version specified in your `cog.yaml`. | ||
| - **System libraries** — common dependencies for machine learning and media processing, including `ffmpeg`, `git`, `curl`, `build-essential`, `cmake`, OpenCV libraries, audio libraries (`sox`, `libsndfile1`), and graphics libraries (`libgl1`, `libsm6`, `libxext6`). | ||
| - **CUDA and PyTorch** (GPU images only) — the appropriate CUDA toolkit and PyTorch stack for your configuration. | ||
| - **Cog runtime** — the Cog SDK and coglet prediction server. | ||
|
|
||
| Base images are tagged by their configuration, for example: | ||
|
|
||
| ``` | ||
| r8.im/cog-base:cuda12-python3.13-torch2.6 | ||
| r8.im/cog-base:python3.13 | ||
| ``` | ||
|
|
||
| When you run `cog build` or `cog push`, Cog selects the base image that matches your Python version, CUDA version, and PyTorch version. Because these images are pre-pulled on Replicate's infrastructure, models built on top of them start faster. | ||
|
|
||
| The entire list of available base images can be viewed at [https://r8.im/v2/cog-base/tags/list](https://r8.im/v2/cog-base/tags/list). | ||
|
|
||
| ## Using the Cog base image | ||
|
|
||
| The `--use-cog-base-image` flag controls whether Cog uses a prebuilt base image. It is **enabled by default** on the following commands: | ||
|
|
||
| - [`cog build`](cli.md#cog-build) | ||
| - [`cog push`](cli.md#cog-push) | ||
| - [`cog run`](cli.md#cog-run) | ||
| - [`cog serve`](cli.md#cog-serve) | ||
| - [`cog exec`](cli.md#cog-exec) | ||
|
|
||
| Since it's on by default, you don't need to pass any flags: | ||
|
|
||
| ```bash | ||
| cog push r8.im/your-username/my-model | ||
| ``` | ||
|
|
||
| This builds and pushes your model using a prebuilt Cog base image for faster cold boots. | ||
|
|
||
| ## Disabling the Cog base image | ||
|
|
||
| If you encounter build issues or need a custom base layer, you can disable the Cog base image: | ||
|
|
||
| ```bash | ||
| cog build --use-cog-base-image=false | ||
| ``` | ||
|
|
||
| When disabled, Cog generates a Dockerfile from scratch using either an NVIDIA CUDA base image or a slim Python base image, depending on the `--use-cuda-base-image` flag. | ||
|
|
||
| ## Relationship to `--use-cuda-base-image` | ||
|
|
||
| The `--use-cuda-base-image` flag controls which underlying base image Cog uses **when the Cog base image is disabled**. It has no effect when `--use-cog-base-image` is enabled (the default), because the Cog base image already includes the appropriate CUDA and Python stack. | ||
|
|
||
| When you disable the Cog base image with `--use-cog-base-image=false`, Cog chooses the base image automatically: | ||
|
|
||
| - **GPU models** (`gpu: true` in `cog.yaml`): uses an NVIDIA CUDA base image. | ||
| - **CPU models**: uses a slim Python base image. | ||
|
|
||
| These flags — along with `--dockerfile` — are **mutually exclusive**: you can only set one of them explicitly on a given command. To customize the base image, disable the Cog base image and let Cog choose between CUDA and Python automatically. | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| If `cog build` or `cog push` fails with the Cog base image enabled, try disabling it: | ||
|
|
||
| ```bash | ||
| cog push --use-cog-base-image=false r8.im/your-username/my-model | ||
| ``` | ||
|
|
||
| This falls back to building from a standard CUDA or Python base image, which can help diagnose whether the issue is with the base image or your model's configuration. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example tag format doesn't match what Cog actually generates. CUDA versions always include the minor version (e.g.,
cuda12.4, notcuda12), and torch versions include the patch level (e.g.,torch2.6.0).