Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker Run Failed - MacOS ARM64 Image #35

Open
seyedasfar opened this issue Mar 20, 2024 · 6 comments
Open

Docker Run Failed - MacOS ARM64 Image #35

seyedasfar opened this issue Mar 20, 2024 · 6 comments
Assignees

Comments

@seyedasfar
Copy link

Hi, Due to conflicts in local package versions with existing projects, unexpected behavior occurred with the local setup. Therefore, I decided to use Docker from the latest commit.

Please let me know if there is any additional information you would like me to provide. Thank you.

      System Version: macOS 14.4
      Chip: Apple M1 Pro
      Memory: 16 GB

Log

user@192 selfie % DOCKER_BUILDKIT=0 docker build --target selfie-arm64 -t selfie:arm64 .

docker run -p 8181:8181 \
  --name selfie-arm64 \
  -v $(pwd)/data:/selfie/data \
  -v $(pwd)/selfie:/selfie/selfie \
  -v $(pwd)/selfie-ui:/selfie/selfie-ui \
  -v $HOME/.cache/huggingface:/root/.cache/huggingface \
  selfie:arm64
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
            BuildKit is currently disabled; enable it by removing the DOCKER_BUILDKIT=0
            environment-variable.

Sending build context to Docker daemon  10.36MB
Step 1/29 : FROM node:18.19-alpine3.18 AS selfie-ui
 ---> 41ad1edd39ed
Step 2/29 : WORKDIR /selfie
 ---> Using cache
 ---> 849eda0c1e62
Step 3/29 : COPY selfie-ui/package.json selfie-ui/yarn.lock ./
 ---> Using cache
 ---> b1d7e1c6b981
Step 4/29 : RUN yarn install --frozen-lockfile --non-interactive
 ---> Using cache
 ---> a6ddc7272287
Step 5/29 : COPY selfie-ui/ .
 ---> Using cache
 ---> 0b60af651610
Step 6/29 : RUN yarn run build
 ---> Using cache
 ---> cc1567a32e0d
Step 7/29 : FROM python:3.11 as selfie-base
 ---> 3a302c046200
Step 8/29 : ENV PYTHONDONTWRITEBYTECODE 1
 ---> Using cache
 ---> e7b04d3c61bc
Step 9/29 : ENV PYTHONUNBUFFERED 1
 ---> Using cache
 ---> 08840518de35
Step 10/29 : ENV PIP_NO_CACHE_DIR=1
 ---> Using cache
 ---> fb9820d52ca0
Step 11/29 : WORKDIR /selfie
 ---> Using cache
 ---> 530a11304303
Step 12/29 : COPY . .
 ---> Using cache
 ---> c3e576595af0
Step 13/29 : COPY --from=selfie-ui /selfie/out/ ./selfie-ui/out
 ---> Using cache
 ---> ddc9cfe500cb
Step 14/29 : RUN pip install poetry --no-cache-dir
 ---> Using cache
 ---> a479a6df0a89
Step 15/29 : RUN poetry config virtualenvs.create false
 ---> Using cache
 ---> f284461f89e0
Step 16/29 : RUN poetry install --no-interaction --no-ansi
 ---> Using cache
 ---> 158869c414b2
Step 17/29 : EXPOSE 8181
 ---> Using cache
 ---> a754619b8236
Step 18/29 : FROM selfie-base as selfie-cpu
 ---> a754619b8236
Step 19/29 : CMD ["python", "-m", "selfie"]
 ---> Using cache
 ---> 32056484b7e6
Step 20/29 : FROM nvcr.io/nvidia/pytorch:23.10-py3 as selfie-gpu
 ---> b7cf5f7ecb71
Step 21/29 : COPY --from=selfie-base /selfie /selfie
 ---> Using cache
 ---> 9c08f725664d
Step 22/29 : WORKDIR /selfie
 ---> Using cache
 ---> 4ec1bbea2345
Step 23/29 : RUN pip install poetry --no-cache-dir
 ---> Using cache
 ---> 20f340333b3a
Step 24/29 : ENV PATH="/root/.local/bin:$PATH"
 ---> Using cache
 ---> b75fec1bc993
Step 25/29 : RUN poetry install --no-interaction --no-ansi
 ---> Using cache
 ---> c706d2228809
Step 26/29 : RUN bash /selfie/scripts/llama-cpp-python-cublas.sh
 ---> Using cache
 ---> 89c3fa68c5dc
Step 27/29 : CMD ["poetry", "run", "python", "-m", "selfie", "--gpu", "--verbose"]
 ---> Using cache
 ---> 20937a99d4a1
Step 28/29 : FROM selfie-base as selfie-arm64
 ---> a754619b8236
Step 29/29 : CMD if [ "$(uname -m)" = "arm64" ]; then         echo "Running with GPU support";         python -m selfie --gpu;     else         echo "Running without GPU support";         python -m selfie;     fi
 ---> Using cache
 ---> 6060df7224a9
Successfully built 6060df7224a9
Successfully tagged selfie:arm64

What's Next?
  View a summary of image vulnerabilities and recommendations → docker scout quickview
Running without GPU support
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/selfie/selfie/__main__.py", line 95, in <module>
    main()
  File "/selfie/selfie/__main__.py", line 80, in main
    app = get_configured_app(shareable=True)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/selfie/selfie/__main__.py", line 68, in get_configured_app
    from selfie.api import app
  File "/selfie/selfie/api/__init__.py", line 88, in <module>
    app.mount("/static", StaticFiles(directory=static_files_dir), name="static")
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/starlette/staticfiles.py", line 59, in __init__
    raise RuntimeError(f"Directory '{directory}' does not exist")
RuntimeError: Directory '/selfie/selfie/api/../web' does not exist
@volod-vana volod-vana self-assigned this Mar 20, 2024
@volod-vana
Copy link
Member

Thanks for bringing this to our attention! I see the problem stems from the volume mapping for selfie-ui. Your workaround is on the right track by simplifying the Docker run command. Let's try this for now:

docker run -p 8181:8181 \
  -v $HOME/.cache/huggingface:/root/.cache/huggingface \
  selfie:arm64

I'll dive deeper into optimizing our Docker setup for ARM64 and fixing the static files issue. Keep an eye out for updates, and please keep the feedback coming—it helps us improve!

Let me know if the workaround does the trick or if you hit any more snags.

@seyedasfar
Copy link
Author

Thank you for the workaround suggestion. Unfortunately, I'm still encountering the same error message.

2024-03-20 23:55:45 Running without GPU support
2024-03-20 23:55:50 Traceback (most recent call last):
2024-03-20 23:55:50   File "<frozen runpy>", line 198, in _run_module_as_main
2024-03-20 23:55:50   File "<frozen runpy>", line 88, in _run_code
2024-03-20 23:55:50   File "/selfie/selfie/__main__.py", line 95, in <module>
2024-03-20 23:55:50     main()
2024-03-20 23:55:50   File "/selfie/selfie/__main__.py", line 80, in main
2024-03-20 23:55:50     app = get_configured_app(shareable=True)
2024-03-20 23:55:50           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-03-20 23:55:50   File "/selfie/selfie/__main__.py", line 68, in get_configured_app
2024-03-20 23:55:50     from selfie.api import app
2024-03-20 23:55:50   File "/selfie/selfie/api/__init__.py", line 88, in <module>
2024-03-20 23:55:50     app.mount("/static", StaticFiles(directory=static_files_dir), name="static")
2024-03-20 23:55:50                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-03-20 23:55:50   File "/usr/local/lib/python3.11/site-packages/starlette/staticfiles.py", line 59, in __init__
2024-03-20 23:55:50     raise RuntimeError(f"Directory '{directory}' does not exist")
2024-03-20 23:55:50 RuntimeError: Directory '/selfie/selfie/api/../web' does not exist

@volod-vana
Copy link
Member

volod-vana commented Mar 21, 2024

Hey @usama-asfar, thanks for flagging this
Can you please try if this works for you? https://github.com/vana-com/selfie/pull/36

This might help with a Docker, but, due to current limitations with Docker on macOS, direct access to Metal APIs is not available for containers. As a result, applications requiring intensive graphics processing may experience reduced performance compared to running natively on macOS.

So if you give more info on your original issue it might be better to resolve it, then use Docker on Mac for inferences due to performance.

@seyedasfar
Copy link
Author

I have encountered into another issue. https://github.com/vana-com/selfie/pull/36.

Here is the complete log.

user@192 selfie % ./docker/build.sh arm64
[+] Building 104.5s (19/19) FINISHED                                               docker:desktop-linux
 => [internal] load build definition from Dockerfile.base                                          0.0s
 => => transferring dockerfile: 545B                                                               0.0s
 => [internal] load metadata for docker.io/library/python:3.11                                     0.0s
 => [internal] load metadata for docker.io/library/node:18-alpine                                  2.9s
 => [auth] library/node:pull token for registry-1.docker.io                                        0.0s
 => [internal] load .dockerignore                                                                  0.0s
 => => transferring context: 60B                                                                   0.0s
 => [selfie-ui 1/6] FROM docker.io/library/node:18-alpine@sha256:c7620fdecfefb96813da625198978087  0.0s
 => [internal] load build context                                                                  0.1s
 => => transferring context: 25.09kB                                                               0.0s
 => [selfie-base 1/7] FROM docker.io/library/python:3.11                                           0.0s
 => CACHED [selfie-base 2/7] WORKDIR /selfie                                                       0.0s
 => CACHED [selfie-base 3/7] COPY . .                                                              0.0s
 => CACHED [selfie-ui 2/6] WORKDIR /selfie                                                         0.0s
 => CACHED [selfie-ui 3/6] COPY selfie-ui/package.json selfie-ui/yarn.lock ./                      0.0s
 => CACHED [selfie-ui 4/6] RUN yarn install --frozen-lockfile --non-interactive                    0.0s
 => CACHED [selfie-ui 5/6] COPY selfie-ui/ .                                                       0.0s
 => CACHED [selfie-ui 6/6] RUN yarn run build                                                      0.0s
 => CACHED [selfie-base 4/7] COPY --from=selfie-ui /selfie/out/ ./selfie-ui/out                    0.0s
 => CACHED [selfie-base 5/7] RUN pip install poetry --no-cache-dir                                 0.0s
 => CACHED [selfie-base 6/7] RUN poetry config virtualenvs.create false                            0.0s
 => ERROR [selfie-base 7/7] RUN poetry install --no-interaction --no-ansi                        102.0s
------                                                                                                  
 > [selfie-base 7/7] RUN poetry install --no-interaction --no-ansi:                                     
0.733 Skipping virtualenv creation, as specified in config file.                                        
0.885 Updating dependencies                                                                             
0.885 Resolving dependencies...                                                                         
60.51                                                                                                   
60.51 Package operations: 92 installs, 0 updates, 0 removals
60.51 
60.51   - Installing h11 (0.14.0)
60.51   - Installing sniffio (1.3.1)
60.51   - Installing typing-extensions (4.10.0)
60.85   - Installing annotated-types (0.6.0)
60.85   - Installing anyio (4.3.0)
60.85   - Installing frozenlist (1.4.1)
60.86   - Installing httpcore (1.0.4)
60.86   - Installing multidict (6.0.5)
60.87   - Installing mypy-extensions (1.0.0)
60.88   - Installing pydantic-core (2.16.3)
60.88   - Installing six (1.16.0)
61.87   - Installing aiosignal (1.3.1)
61.87   - Installing attrs (23.2.0)
61.87   - Installing click (8.1.7)
61.87   - Installing distro (1.9.0)
61.88   - Installing greenlet (3.0.3)
61.88   - Installing httpx (0.27.0)
61.88   - Installing joblib (1.3.2)
61.88   - Installing marshmallow (3.21.1)
61.88   - Installing numpy (1.26.4)
61.88   - Installing pydantic (2.6.4)
61.88   - Installing python-dateutil (2.9.0.post0)
61.89   - Installing pytz (2024.1)
61.99   - Installing regex (2023.12.25)
62.00   - Installing tqdm (4.66.2)
62.00   - Installing typing-inspect (0.9.0)
62.05   - Installing tzdata (2024.1)
62.06   - Installing wrapt (1.16.0)
62.13   - Installing yarl (1.9.4)
67.08   - Installing aiohttp (3.9.3)
67.08   - Installing dataclasses-json (0.6.4)
67.08   - Installing deprecated (1.2.14)
67.08   - Installing dirtyjson (1.0.8)
67.08   - Installing fsspec (2024.2.0)
67.08   - Installing llamaindex-py-client (0.1.13)
67.08   - Installing markupsafe (2.1.5)
67.08   - Installing mpmath (1.3.0)
67.09   - Installing nest-asyncio (1.6.0)
67.09   - Installing networkx (3.2.1)
67.09   - Installing nltk (3.8.1)
67.09   - Installing openai (1.14.2)
67.14   - Installing pandas (2.2.1)
67.16   - Installing pillow (10.2.0)
67.17   - Installing pyyaml (6.0.1)
67.20   - Installing sqlalchemy (2.0.28)
67.23   - Installing tenacity (8.2.3)
67.46   - Installing tiktoken (0.6.0)
75.34   - Installing huggingface-hub (0.21.4)
75.34   - Installing jinja2 (3.1.3)
75.34   - Installing llama-index-core (0.10.21.post1)
75.34   - Installing sympy (1.12)
80.58   - Installing llama-index-llms-openai (0.1.12)
80.58   - Installing safetensors (0.4.2)
80.58   - Installing soupsieve (2.5)
80.58   - Installing tokenizers (0.15.2)
80.58   - Installing torch (2.2.1)
96.64   - Installing beautifulsoup4 (4.12.3)
96.64   - Installing llama-index-agent-openai (0.1.6)
96.64   - Installing pymupdfb (1.24.0)
96.64   - Installing transformers (4.39.0)
96.67 
96.67   RuntimeError
96.67 
96.67   Unable to find installation candidates for pymupdfb (1.24.0)
96.67 
96.67   at /usr/local/lib/python3.11/site-packages/poetry/installation/chooser.py:74 in choose_for
96.67        70│ 
96.67        71│             links.append(link)
96.67        72│ 
96.67        73│         if not links:
96.67     →  74│             raise RuntimeError(f"Unable to find installation candidates for {package}")
96.67        75│ 
96.67        76│         # Get the best link
96.67        77│         chosen = max(links, key=lambda link: self._sort_key(package, link))
96.67        78│ 
96.67 
96.67 Cannot install pymupdfb.
96.67 
------
Dockerfile.base:17
--------------------
  15 |     RUN pip install poetry --no-cache-dir
  16 |     RUN poetry config virtualenvs.create false
  17 | >>> RUN poetry install --no-interaction --no-ansi
--------------------
ERROR: failed to solve: process "/bin/sh -c poetry install --no-interaction --no-ansi" did not complete successfully: exit code: 1

View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/b0qqp27fkf7mxti4wapjzt5vx
[+] Building 2.1s (3/3) FINISHED                                                   docker:desktop-linux
 => [internal] load build definition from Dockerfile.arm64                                         0.0s
 => => transferring dockerfile: 140B                                                               0.0s
 => ERROR [internal] load metadata for docker.io/library/selfie-base:latest                        2.0s
 => [auth] library/selfie-base:pull token for registry-1.docker.io                                 0.0s
------
 > [internal] load metadata for docker.io/library/selfie-base:latest:
------
Dockerfile.arm64:1
--------------------
   1 | >>> FROM selfie-base as selfie-arm64
   2 |     EXPOSE 8181
   3 |     CMD ["python", "-m", "selfie", "--gpu", "--verbose"]
--------------------
ERROR: failed to solve: selfie-base: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed

View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/n6a4l9q359l2ucvcbs36c0wkq

My original issue was with package version configuration within my existing projects (version-sensitive). I had to switch between package versions in the workspace, and it's quite a pain.

Thank you for your support, @volod-vana. If this issue persists or if it seems to be a system/configuration problem is specific only to me, I will switch back to running natively on my machine.

@volod-vana
Copy link
Member

Hey @usama-asfar thanks for the details and for your patience. I did update that PR again, can you please update and try again?

I'm looking into using conda for dev environment on mac for better performance, but so far I'm getting segmentation faults when running inferences that way. I will update you once that available or if we will find some other solution that will not require switching between package versions.

@seyedasfar
Copy link
Author

Although the build was successful, it failed with the same error. Let's keep the issue open and please keep me updated here. I will set up Selfie locally. Thank you @volod-vana.

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/selfie/selfie/__main__.py", line 95, in <module>
    main()
  File "/selfie/selfie/__main__.py", line 80, in main
    app = get_configured_app(shareable=True)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/selfie/selfie/__main__.py", line 68, in get_configured_app
    from selfie.api import app
  File "/selfie/selfie/api/__init__.py", line 88, in <module>
    app.mount("/static", StaticFiles(directory=static_files_dir), name="static")
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/starlette/staticfiles.py", line 59, in __init__
    raise RuntimeError(f"Directory '{directory}' does not exist")
RuntimeError: Directory '/selfie/selfie/api/../web' does not exist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants