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

Can I run docker on M chips Mac? #13

Open
windmemory opened this issue Jul 3, 2024 · 5 comments
Open

Can I run docker on M chips Mac? #13

windmemory opened this issue Jul 3, 2024 · 5 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@windmemory
Copy link

What I did:

On my MBP, M1 Max

docker pull savatar101/omniparse:0.1
docker run -p 8000:8000 savatar101/omniparse:0.1

Then I got the below output:

==========
== CUDA ==
==========

CUDA Version 11.8.0

Container image Copyright (c) 2016-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.

This container image and its contents are governed by the NVIDIA Deep Learning Container License.
By pulling and using the container, you accept the terms and conditions of this license:
https://developer.nvidia.com/ngc/nvidia-deep-learning-container-license

A copy of this license is made available in this container at /NGC-DL-CONTAINER-LICENSE for your convenience.

WARNING: The NVIDIA Driver was not detected.  GPU functionality will not be available.
   Use the NVIDIA Container Toolkit to start this container with GPU support; see
   https://docs.nvidia.com/datacenter/cloud-native/ .

/opt/nvidia/nvidia_entrypoint.sh: line 67: exec: --: invalid option
exec: usage: exec [-cl] [-a name] [command [argument ...]] [redirection ...]

Not sure what I did was wrong, but can not run this docker on my Mac. Anyone knows how to do this?

@qyou
Copy link

qyou commented Jul 4, 2024

  1. You should git clone this repo and cp Dockerfile to Dockerfile.cpu.arm64 and revise as follows:
ARG MAX_JOBS=4

FROM ubuntu:22.04  # <-- Revise here

# Update package lists and install necessary packages
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    wget \
    curl \
    unzip \
    git \
    python3 \
    python3-pip \
    libgl1 \
    libglib2.0-0 \
    curl \
    gnupg2 \
    ca-certificates \
    apt-transport-https \
    software-properties-common \
    libreoffice \
    ffmpeg \
    git-lfs \
    xvfb \
    && ln -s /usr/bin/python3 /usr/bin/python \
    && curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash \
    && wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \
    && echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list \
    && apt-get update \
    && apt install python3-packaging \
    && apt-get install -y --no-install-recommends google-chrome-stable \
    && rm -rf /var/lib/apt/lists/*

# Add essential fonts to support Chinese  <-- If you want to support Chines, add the following command
RUN apt-get install fonts-noto-cjk fonts-noto-cjk-extra fonts-arphic-ukai fonts-arphic-uming fonts-wqy-microhei fonts-wqy-zenhei \
    && apt-get clean && rm -rf /var/lib/apt/lists/* \
    && fc-cache -fv

# Download and install ChromeDriver
RUN CHROMEDRIVER_VERSION=$(curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE) && \
    wget -N https://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip -P /tmp && \
    unzip /tmp/chromedriver_linux64.zip -d /tmp && \
    mv /tmp/chromedriver /usr/local/bin/chromedriver && \
    chmod +x /usr/local/bin/chromedriver && \
    rm /tmp/chromedriver_linux64.zip

# Copy Chromedriver from the builder stage (if applicable)
# COPY --from=builder /usr/local/bin/chromedriver /usr/local/bin/chromedriver

# Install PyTorch and related packages
RUN pip3 install --no-cache-dir torch torchvision torchaudio  # <-- Revised here

# Set up working directory and copy application code
COPY . /app
WORKDIR /app

# Install Python package (assuming it has a setup.py)
RUN pip3 install --no-cache-dir -e .

RUN pip install transformers==4.41.2

# Set environment variables
ENV CHROME_BIN=/usr/bin/google-chrome \
    CHROMEDRIVER=/usr/local/bin/chromedriver \
    DISPLAY=:99 \
    DBUS_SESSION_BUS_ADDRESS=/dev/null \
    PYTHONUNBUFFERED=1

# Ensure the PATH environment variable includes the location of the installed packages
ENV PATH /usr/local/bin:$PATH

# Expose the desired port
ENV PORT=8000
EXPOSE ${PORT}

# Run the server
CMD ["python", "server.py", "--host", "0.0.0.0", "--documents", "--media", "--web"]
  1. Build a image by yourself.
docker build --arch=arm64 -f Dockerfile.cpu.arm64 -t  omniparse:0.1-arm64 .

While I don't have a Macbook at hand. You can test it and submit a PR, which is a big welcome.

@windmemory
Copy link
Author

Will give it a try first, if it works, will try to submit a PR.

@adithya-s-k
Copy link
Owner

@windmemory @qyou Unfortunately, I don't have access to a MacBook.
@windmemory A PR would be much appreciated, but it might have some underlying complexity due to dealing with dependencies.

@adithya-s-k adithya-s-k added enhancement New feature or request help wanted Extra attention is needed labels Jul 4, 2024
@windmemory
Copy link
Author

@adithya-s-k Understand, thanks for the reply. I tried on my Mac, but I got network issue connecting to dockerhub (since I am in China T T), still trying to figure out a way to build the image.

@windmemory
Copy link
Author

First blocker: no chrome available for arm. So is Chromium compatible in this project? Or only Chrome is okay? @adithya-s-k @qyou

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants