replicate / cog

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

Getting Started process fails on M1 Mac #273

Closed zeke closed 2 years ago

zeke commented 3 years ago

I'm going through the Getting started guide and got an error during the build process:

The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

Here's the full output:

~/git/zeke/cog-quickstart
$ /usr/local/bin/cog predict -i @input.jpg
Building Docker image from environment in cog.yaml...
[+] Building 114.9s (13/13) FINISHED                                                                                                                          
 => [internal] load build definition from Dockerfile                                                                                                     0.0s
 => => transferring dockerfile: 592B                                                                                                                     0.0s
 => [internal] load .dockerignore                                                                                                                        0.0s
 => => transferring context: 2B                                                                                                                          0.0s
 => resolve image config for docker.io/docker/dockerfile:1.2                                                                                             0.5s
 => CACHED docker-image://docker.io/docker/dockerfile:1.2@sha256:e2a8561e419ab1ba6b2fe6cbdf49fd92b95912df1cf7d313c3e2230a333fdbcc                        0.0s
 => [internal] load metadata for docker.io/library/python:3.8                                                                                            0.5s
 => [internal] load build context                                                                                                                        0.0s
 => => transferring context: 13.68kB                                                                                                                     0.0s
 => CACHED [stage-0 1/5] FROM docker.io/library/python:3.8@sha256:0f594721ed51e1cccd5881f979a7b42ee7109d22749d246fc41d0e3ef4a52ba1                       0.0s
 => [stage-0 2/5] COPY .cog/tmp/build1291097786/cog-0.0.1.dev-py3-none-any.whl /tmp/cog-0.0.1.dev-py3-none-any.whl                                       0.0s
 => [stage-0 3/5] RUN --mount=type=cache,target=/root/.cache/pip pip install /tmp/cog-0.0.1.dev-py3-none-any.whl                                        12.0s
 => [stage-0 4/5] RUN --mount=type=cache,target=/root/.cache/pip pip install   pillow==8.3.1 tensorflow==2.5.0                                          98.9s
 => [stage-0 5/5] WORKDIR /src                                                                                                                           0.0s 
 => exporting to image                                                                                                                                   0.0s 
 => => exporting layers                                                                                                                                  0.0s 
 => => writing image sha256:40550d31a34c727e5c7941673e7ee90cf6b155178c3d4bb03d6b9737117bad92                                                             0.0s 
 => => naming to docker.io/library/cog-cog-quickstart-base                                                                                               0.0s 
 => exporting cache                                                                                                                                      0.0s 
 => => preparing build cache for export                                                                                                                  0.0s

Starting Docker image cog-cog-quickstart-base and running setup()...
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
2021-09-29 17:45:33.092137: F tensorflow/core/lib/monitoring/sampler.cc:42] Check failed: bucket_limits_[i] > bucket_limits_[i - 1] (0 vs. 10)
qemu: uncaught target signal 6 (Aborted) - core dumped
^C

I saw I was behind a few versions (current latest is 0.0.13):

$ /usr/local/bin/cog --version            
cog version 0.0.11 (built 2021-09-13T18:48:30Z)

So I attempted to upgrade to the latest cog:

$ sudo curl -o /usr/local/bin/cog -L https://github.com/replicate/cog/releases/latest/download/cog_`uname -s`_`uname -m`
sudo chmod +x /usr/local/bin/cog

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   141  100   141    0     0    594      0 --:--:-- --:--:-- --:--:--   592
100   624  100   624    0     0   1444      0 --:--:-- --:--:-- --:--:--  1444
100 8256k  100 8256k    0     0  9225k      0 --:--:-- --:--:-- --:--:-- 9225k

But the latest release seems to be corrupted or something:

$ /usr/local/bin/cog --version                                                                                          
zsh: killed     /usr/local/bin/cog --version

$ echo "https://github.com/replicate/cog/releases/latest/download/cog_`uname -s`_`uname -m`"                      
https://github.com/replicate/cog/releases/latest/download/cog_Darwin_arm64
zeke commented 3 years ago

Update: I was able to get the latest cog after all by first rming the old /usr/local/bin/cog:

sudo rm /usr/local/bin/cog
zeke commented 3 years ago

Still seeing the core dump when using the latest cog 0.0.13. Here's the output with the --debug flag added:

$ /usr/local/bin/cog predict -i @input.jpg --debug     
Building Docker image from environment in cog.yaml...
$ docker buildx build --platform linux/amd64 --file - --build-arg BUILDKIT_INLINE_CACHE=1 --tag cog-cog-quickstart-base --progress auto .
[+] Building 3.2s (13/13) FINISHED                                                                                                                                                                                                                                                                                            
 => [internal] load build definition from Dockerfile                                                                                                                                                                                                                                                                     0.0s
 => => transferring dockerfile: 592B                                                                                                                                                                                                                                                                                     0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                                                                                                        0.0s
 => => transferring context: 2B                                                                                                                                                                                                                                                                                          0.0s
 => resolve image config for docker.io/docker/dockerfile:1.2                                                                                                                                                                                                                                                             2.3s
 => CACHED docker-image://docker.io/docker/dockerfile:1.2@sha256:e2a8561e419ab1ba6b2fe6cbdf49fd92b95912df1cf7d313c3e2230a333fdbcc                                                                                                                                                                                        0.0s
 => [internal] load metadata for docker.io/library/python:3.8                                                                                                                                                                                                                                                            0.6s
 => [internal] load build context                                                                                                                                                                                                                                                                                        0.0s
 => => transferring context: 14.56kB                                                                                                                                                                                                                                                                                     0.0s
 => [stage-0 1/5] FROM docker.io/library/python:3.8@sha256:0f594721ed51e1cccd5881f979a7b42ee7109d22749d246fc41d0e3ef4a52ba1                                                                                                                                                                                              0.0s
 => CACHED [stage-0 2/5] COPY .cog/tmp/build2802701736/cog-0.0.1.dev-py3-none-any.whl /tmp/cog-0.0.1.dev-py3-none-any.whl                                                                                                                                                                                                0.0s
 => CACHED [stage-0 3/5] RUN --mount=type=cache,target=/root/.cache/pip pip install /tmp/cog-0.0.1.dev-py3-none-any.whl                                                                                                                                                                                                  0.0s
 => CACHED [stage-0 4/5] RUN --mount=type=cache,target=/root/.cache/pip pip install   pillow==8.3.1 tensorflow==2.5.0                                                                                                                                                                                                    0.0s
 => CACHED [stage-0 5/5] WORKDIR /src                                                                                                                                                                                                                                                                                    0.0s
 => exporting to image                                                                                                                                                                                                                                                                                                   0.0s
 => => exporting layers                                                                                                                                                                                                                                                                                                  0.0s
 => => writing image sha256:d49701d400c17813dbc5fc684080ec652a77c9d92cd82af3e0377139f601cba1                                                                                                                                                                                                                             0.0s
 => => naming to docker.io/library/cog-cog-quickstart-base                                                                                                                                                                                                                                                               0.0s
 => exporting cache                                                                                                                                                                                                                                                                                                      0.0s
 => => preparing build cache for export                                                                                                                                                                                                                                                                                  0.0s

Starting Docker image cog-cog-quickstart-base and running setup()...
$ docker run --rm --shm-size 8G --detach --publish 5081:5000 --mount type=bind,source=/Users/z/git/zeke/cog-quickstart,destination=/src cog-cog-quickstart-base
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
2021-09-29 18:28:21.465093: F tensorflow/core/lib/monitoring/sampler.cc:42] Check failed: bucket_limits_[i] > bucket_limits_[i - 1] (0 vs. 10)
qemu: uncaught target signal 6 (Aborted) - core dumped
zeke commented 3 years ago

One idea: Update the getting started guide to use a Torch example instead of Tensorflow, as Torch probably works on M1.

zeke commented 2 years ago

The problem persists but I'm going to close this issue in favor of https://github.com/replicate/cog/issues/336

xcreateadmin commented 1 year ago

Same issue on mac m1

qhkm commented 1 year ago

Same issue on macbook air m2

sentient-22 commented 1 year ago

same issue on m2

tostangs commented 1 year ago

issue is still persisting on M1, can't "replicate" any of the basic cog examples.

nmnduy commented 1 year ago

Go to this page and find the version and binary for your OS

https://github.com/replicate/cog/releases

for my mac M1 e.g. default.cog_darwin_arm64

enisze commented 1 year ago

For me it also fails with this error:

image
zeke-john commented 8 months ago

same error here

Any update?

Info: Darwin Zekes-MacBook-Air.local 23.1.0 Darwin Kernel Version 23.1.0: Mon Oct 9 21:28:12 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T8103 arm64

Screenshot 2024-02-24 at 3 38 00 PM