replicate / cog

Containers for machine learning
https://cog.run
Apache License 2.0
8.08k stars 561 forks source link

Document how to use `docker cp` to get weights out of a model #399

Open bfirsh opened 2 years ago

bfirsh commented 2 years ago

Your model weights are inside the Cog Docker image. This makes it useful as an artifact for versioning and storing model weights.

One could imagine a feature of Cog that could get weights out, but a simple first step might be to document how model authors can do it with docker cp.

For example, here is something I wrote to get the weights out of a model on Replicate:

#!/bin/bash
id=$(docker create r8.im/f90/wave-u-net-pytorch)
docker cp $id:/src/checkpoints ./
zeke commented 2 years ago

An example in the wild: https://github.com/f90/Wave-U-Net-Pytorch/pull/12/commits/cbca549841c184798f66f4170324c2efd6838463

bfirsh commented 2 years ago

@evilstreak That thing you were saying the other day about struggling to get erlich rebuilt with a newer Cog reminded me of this. You probably could have ran this to rebuild it:

mkdir erlich-scratch
cd erlich-scratch
id=$(docker create r8.im/laion-ai/erlich)
docker cp $id:/src ./
cog build r8.im/laion-ai/erlich

Maybe we should document this in a "Cookbook" or something, alongside the thing mentioned in the original post!