replicate / cog

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

Unable to install a git-hosted Python package in cog.yaml #1381

Closed zeke closed 11 months ago

zeke commented 1 year ago

I'm getting this error when trying to cog build using a git-hosted dependency in my cog.yaml file:

#0 2.884   ERROR: Error [Errno 2] No such file or directory: 'git' while executing command git version                                                        
#0 2.886 ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?

$ cog --version
cog version 0.8.6 (built 2023-08-07T23:02:15+0000)
$ cat cog.yaml
build:
  gpu: false
  python_packages:
    - "git+https://github.com/m-bain/whisperX.git"

predict: "predict.py:Predictor"

$ cog build   
Building Docker image from environment in cog.yaml as cog-video-transcriber...
[+] Building 38.1s (14/16)                                                                                                                                    
 => [internal] load build definition from Dockerfile                                                                                                     0.0s
 => => transferring dockerfile: 1.07kB                                                                                                                   0.0s
 => [internal] load .dockerignore                                                                                                                        0.0s
 => => transferring context: 35B                                                                                                                         0.0s
 => resolve image config for docker.io/docker/dockerfile:1.4                                                                                             1.1s
 => CACHED docker-image://docker.io/docker/dockerfile:1.4@sha256:9ba7531bd80fb0a858632727cf7a112fbfd19b17e94c4e84ced81e24ef1a0dbc                        0.0s
 => [internal] load .dockerignore                                                                                                                        0.0s
 => [internal] load build definition from Dockerfile                                                                                                     0.0s
 => [internal] load metadata for docker.io/library/python:3.8-slim                                                                                       0.8s
 => [internal] load build context                                                                                                                        0.0s
 => => transferring context: 1.66MB                                                                                                                      0.0s
 => [stage-0 1/8] FROM docker.io/library/python:3.8-slim@sha256:9187d27fd8f222a181292f24f8e7d6b22419d46bd9cc4506adbdf2dcfae68a56                         0.0s
 => CACHED [stage-0 2/8] RUN --mount=type=cache,target=/var/cache/apt set -eux; apt-get update -qq; apt-get install -qqy --no-install-recommends curl;   0.0s
 => [stage-0 3/8] COPY .cog/tmp/build2377246762/cog-0.0.1.dev-py3-none-any.whl /tmp/cog-0.0.1.dev-py3-none-any.whl                                       0.0s
 => [stage-0 4/8] RUN --mount=type=cache,target=/root/.cache/pip pip install /tmp/cog-0.0.1.dev-py3-none-any.whl                                        32.8s
 => [stage-0 5/8] COPY .cog/tmp/build2377246762/requirements.txt /tmp/requirements.txt                                                                   0.0s 
 => ERROR [stage-0 6/8] RUN --mount=type=cache,target=/root/.cache/pip pip install -r /tmp/requirements.txt                                              3.1s 
------                                                                                                                                                        
 > [stage-0 6/8] RUN --mount=type=cache,target=/root/.cache/pip pip install -r /tmp/requirements.txt:                                                         
#0 2.869 Collecting git+https://github.com/m-bain/whisperX.git@befe2b242eb59dcd7a8a122d127614d5c63d36e9 (from -r /tmp/requirements.txt (line 1))              
#0 2.873   Cloning https://github.com/m-bain/whisperX.git (to revision befe2b242eb59dcd7a8a122d127614d5c63d36e9) to /tmp/pip-req-build-h5qmupmq               
#0 2.884   ERROR: Error [Errno 2] No such file or directory: 'git' while executing command git version                                                        
#0 2.886 ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?
zeke commented 1 year ago

I think I found a workaround by adding git to system_packages in cog.yaml, but I don't think this used to be necessary:

build:
  gpu: false
  system_packages:
    - "git"
  python_packages:
    - "git+https://github.com/m-bain/whisperX.git"

predict: "predict.py:Predictor"

Seems like maybe a regression in Cog? Or maybe something is hosed in my local Docker config...

mattt commented 1 year ago

@zeke This changed in https://github.com/replicate/cog/pull/1214, when we switched to using a Python slim base image that doesn't include git.

I'm not sure what we've promised in the past about supporting Git dependencies, or to what extent that's expected behavior, though.