replicate / cog

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

examples Resnet Pydantic 1.10.2 not compatible #785

Open tansangxtt opened 2 years ago

tansangxtt commented 2 years ago

In the current example Resnet,

cog build

generates the following error logs:

Building Docker image from environment in cog.yaml as cog-resnet...
[+] Building 69.4s (14/14) FINISHED                                                                              
 => [internal] load build definition from Dockerfile                                                        0.0s
 => => transferring dockerfile: 622B                                                                        0.0s 
 => [internal] load .dockerignore                                                                           0.0s 
 => => transferring context: 2B                                                                             0.0s 
 => resolve image config for docker.io/docker/dockerfile:1.2                                                1.5s 
 => CACHED docker-image://docker.io/docker/dockerfile:1.2@sha256:e2a8561e419ab1ba6b2fe6cbdf49fd92b95912df1  0.0s
 => [internal] load metadata for docker.io/library/python:3.9                                               2.3s 
 => [stage-0 1/6] FROM docker.io/library/python:3.9@sha256:475fe86ebf1da48ea27009a8f7d7e96231af4142de918a6  1.7s
 => => resolve docker.io/library/python:3.9@sha256:475fe86ebf1da48ea27009a8f7d7e96231af4142de918a68010d48d  0.0s
 => => sha256:b5f024fa682187ef9305a2b5d2c4bb583bef83356259669fc80273bb2222f5ed 2.22kB / 2.22kB              0.0s 
 => => sha256:ab0d2f900193d5847eb02cbfaa0b956337a1d877cb9fae009e06cd300586de1d 8.51kB / 8.51kB              0.0s 
 => => sha256:475fe86ebf1da48ea27009a8f7d7e96231af4142de918a68010d48d0abb9c9c5 1.86kB / 1.86kB              0.0s 
 => => sha256:b8127bb1e87b053f8138f6a14a15d370c13164f844d3b8886a39e803ffa896e7 18.31MB / 18.31MB            0.5s 
 => => sha256:f3b0eb11a35935243a2b303a6aaf782af9ae111b3b8aab0c1c0281757b38cb1c 233B / 233B                  0.8s
 => => sha256:07d95c49563f1643ba84fd970da0cb4693fd5c4316545c0ec8468aeb640904df 2.88MB / 2.88MB              0.6s
 => => extracting sha256:b8127bb1e87b053f8138f6a14a15d370c13164f844d3b8886a39e803ffa896e7                   0.6s
 => => extracting sha256:f3b0eb11a35935243a2b303a6aaf782af9ae111b3b8aab0c1c0281757b38cb1c                   0.0s 
 => => extracting sha256:07d95c49563f1643ba84fd970da0cb4693fd5c4316545c0ec8468aeb640904df                   0.2s 
 => [internal] load build context                                                                           0.0s 
 => => transferring context: 32.19kB                                                                        0.0s 
 => [stage-0 2/6] COPY .cog/tmp/build3192047579/cog-0.0.1.dev-py3-none-any.whl /tmp/cog-0.0.1.dev-py3-none  0.1s 
 => [stage-0 3/6] RUN --mount=type=cache,target=/root/.cache/pip pip install /tmp/cog-0.0.1.dev-py3-none-  15.0s
 => [stage-0 4/6] RUN --mount=type=cache,target=/root/.cache/pip pip install   pillow==8.3.1 tensorflow==  39.0s 
 => [stage-0 5/6] WORKDIR /src                                                                              0.1s 
 => [stage-0 6/6] COPY . /src                                                                               0.2s 
 => exporting to image                                                                                      0.0s 
 => => exporting layers                                                                                     0.0s 
 => => writing image sha256:90d08dc9b30b68172184351426413c3dbf08eea85b9eddd47eb9988fac268472                0.0s 
 => => naming to docker.io/library/cog-resnet                                                               0.0s 
 => exporting cache                                                                                         0.0s
 => => preparing build cache for export                                                                     0.0s 

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
Adding labels to image...

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/runpy.py", line 188, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/local/lib/python3.9/runpy.py", line 111, in _get_module_details
    __import__(pkg_name)
  File "/usr/local/lib/python3.9/site-packages/cog/__init__.py", line 1, in <module>
    from pydantic import BaseModel
  File "pydantic/__init__.py", line 2, in init pydantic.__init__
  File "pydantic/dataclasses.py", line 52, in init pydantic.dataclasses
    #   +--- init= parameter
ImportError: cannot import name dataclass_transform

My workaround is to downgrade the pydantic 1.10.1, and it leads to my cog.yaml changed into:

build:
  python_version: "3.9"
  python_packages:
    - "pillow==8.3.1"
    - "tensorflow==2.10.0"
    - "pydantic==1.10.1"
predict: "predict.py:Predictor"
mad-wizard commented 1 year ago

This fix unfortunately does not work for me

#0 10.15 ERROR: Cannot install -r /tmp/requirements.txt (line 10), -r /tmp/requirements.txt (line 11) and -r /tmp/requirements.txt (line 2) because these package versions have conflicting dependencies.
#0 10.15 
#0 10.15 The conflict is caused by:
#0 10.15     tensorflow-gpu 2.8.0 depends on typing-extensions>=3.6.6
#0 10.15     apache-beam 2.34.0 depends on typing-extensions<4 and >=3.7.0
#0 10.15     pydantic 1.10.1 depends on typing-extensions>=4.1.0
#0 10.15 
#0 10.15 To fix this you could try to:
#0 10.15 1. loosen the range of package versions you've specified
#0 10.15 2. remove package versions to allow pip attempt to solve the dependency conflict
#0 10.15 
#0 10.15 ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts
#0 10.15 
#0 10.15 [notice] A new release of pip is available: 23.0.1 -> 23.2.1
#0 10.15 [notice] To update, run: pip install --upgrade pip
------
ERROR: failed to solve: executor failed running [/bin/sh -c pip install -r /tmp/requirements.txt]: exit code: 1
ⅹ Failed to build Docker image: exit status 1