Skip to content

Instantly share code, notes, and snippets.

@anotherjesse
Last active February 7, 2023 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anotherjesse/e0db9a7a13c9d07ff0d36b7771fa2c65 to your computer and use it in GitHub Desktop.
Save anotherjesse/e0db9a7a13c9d07ff0d36b7771fa2c65 to your computer and use it in GitHub Desktop.
weights workaround

big picture

Build your docker image in a way that works with replicate, while limiting image "layers" to less than 20GB.

Steps

Build COG without weights

First build a version of the cog without weights. To do this ensure remove extra files/weights from your cog directory and then build.

$ cog build

 => => writing image sha256:f6e8050651b29b27399418ac28759fcf53bcfdea9fb5b94f450a6d820f0d137f                   0.0s 
 => => naming to docker.io/library/cog-hello-world                                                             0.0s 
 => exporting cache                                                                                            0.0s
 => => preparing build cache for export                                                                        0.0s
Adding labels to image...                                                                                           

Image built as cog-your-project                                                                                      

Prep for build

Create a Dockerfile:

FROM cog-your-project:latest

COPY large-file-1 /src/large-file-1
COPY large-file-2 /src/large-file-2

Note: each large-file-1 can be an individual file or directory. The goal is to not have layers that are so large that the auth token times out during push.

Build and Push

Then build it

$ docker build -t r8.im/username/modelname .

And push it

$ docker push r8.im/username/modelname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment