Automatically construct cog.yaml from a repository

pip install cogreqs==0.0.6



Cogreqs is an experimental drop-in replacement for cog init that intelligently populates cog.yaml.


pip install cogreqs


Run the following command in an existing Python repository:

$ cogreqs --gpu .

Wrote cog.yaml

cog.yaml may now contain something like

# Configuration for Cog ⚙
# Reference:

  # set to true if your model requires a GPU
  gpu: true

  # a list of ubuntu apt packages to install
    - "ffmpeg"
    - "libsndfile-dev"

  # python version in the form '3.8' or '3.8.12'
  python_version: "3.8"

  # a list of packages in the format <package-name>==<version>
    - "librosa==0.9.1"
    - "numpy==1.22.2"
    - "scipy==1.8.0"
    - "torch==1.10.2"

  # commands run after the environment is setup

# defines how predictions are run on your model
predict: ""

NOTE: Cogreqs outputs a that's only compatible with the future branch of Cog. Until that branch is merged into main, install Cog from

You can also output the generated cog.yaml contents to stdout:

$ cogreqs --config-path=- --predict-path=/dev/null .

# Configuration for Cog ⚙
# Reference:


CLI reference

usage: cogreqs [-h] [-f] [-g] [--config-path CONFIG_PATH] [--predict-path PREDICT_PATH] folder

Generate cog.yaml and from an existing repository. This is an experimental alternative to
cog init

positional arguments:
  folder                Project folder

optional arguments:
  -h, --help            show this help message and exit
  -f, --force-overwrite
                        Overwrite existing cog.yaml and
  -g, --gpu             Use GPU
  --config-path CONFIG_PATH
                        Config file path (default cog.yaml)
  --predict-path PREDICT_PATH
                        Predict file path (default

How does it work?

Cogreqs uses pipreqs to extract requirements from Python files in a repository. It then applies a sequence of heuristics on those requirements to populate python_packages and system_packages in cog.yaml.

For example, cogreqs knows that librosa requires the ffmpeg and libsndfile-dev system packages so it will add those to system_packages if librosa is one of the python requirements.

Work in progress!

This project is very much work in progress. Please submit an issue or pull request if you have ideas for heuristics or other features!