首页 > 解决方案 > 在 Google Cloud Run 中容器化应用程序时出现 Docker 错误

问题描述

我正在尝试从Google Cloud Run 中的拥抱脸运行变形金刚。

我的第一个想法是运行一个由 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

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"]

来自 Google Cloud Run文档的 .dockerignore 文件:

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

- - 编辑:

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

COPY . ./

标签: google-cloud-platformdockerfilegoogle-cloud-runhuggingface-transformersgoogle-cloud-sdk

解决方案


错误是:

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 项目。

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


推荐阅读