Docker 在 Google 云 运行 中容器化应用程序时出错

Docker error when containerizing app in Google Cloud Run

我正尝试 运行 transformers from huggingface 在 Google Cloud 运行 中 运行。

我的第一个想法是 运行 huggingface 提供的其中一个 dockerfile,但似乎不可能。

关于如何解决此错误的任何想法?

Step 6/9 : WORKDIR /workspace
 ---> Running in xxx
Removing intermediate container xxx
 ---> xxx
Step 7/9 : COPY . transformers/
 ---> xxx
Step 8/9 : RUN cd transformers/ &&     python3 -m pip install --no-cache-dir .
 ---> Running in xxx
←[91mERROR: Directory '.' is not installable. Neither 'setup.py' nor 'pyproject.toml' found.
The command '/bin/sh -c cd transformers/ &&     python3 -m pip install --no-cache-dir .' returned a non-zero code: 1
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 1
←[0m
-------------------------------------------------------------------------------------------------------------------------------------------------------------------

ERROR: (gcloud.builds.submit) build xxx completed with status "FAILURE"

Dockerfile 来自 huggingface:

FROM nvidia/cuda:10.1-cudnn7-runtime-ubuntu18.04
LABEL maintainer="Hugging Face"
LABEL repository="transformers"

RUN apt update && \
    apt install -y bash \
                   build-essential \
                   git \
                   curl \
                   ca-certificates \
                   python3 \
                   python3-pip && \
    rm -rf /var/lib/apt/lists

RUN python3 -m pip install --no-cache-dir --upgrade pip && \
    python3 -m pip install --no-cache-dir \
    mkl \
    tensorflow

WORKDIR /workspace
COPY . transformers/
RUN cd transformers/ && \
    python3 -m pip install --no-cache-dir .

CMD ["/bin/bash"]

.dockerignore 来自 Google 云的文件 运行 documentation:

Dockerfile
README.md
*.pyc
*.pyo
*.pyd
__pycache__
.pytest_cache

---- 编辑:

设法根据 Dustin 的回答开始工作。我基本上:

COPY . ./

错误是:

Directory '.' is not installable. Neither 'setup.py' nor 'pyproject.toml' found.

这是由于您 Dockerfile:

中的这两行
COPY . transformers/
RUN cd transformers/ && \
    python3 -m pip install --no-cache-dir .

这会尝试将包含 Dockerfile 的本地目录复制到容器中,然后将其安装为 Python 项目。

看起来 Dockerfile 应该是 运行 在 https://github.com/huggingface/transformers 的存储库根目录中。您应该克隆 repo 并将要构建的 Dockerfile 移动到根目录中,然后再次构建。