在Google Cloud Run中对应用程序进行容器化时的Docker错误

问题描述

我正在尝试从transformers在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"

来自huggingface的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"]

.dockerignore来自Google Cloud Run documentation文件

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

----编辑:

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

  • 将Dockerfile和转换器文件夹一起留在根文件夹中。
  • 将dockerfile中的copY行更新为:
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的存储库根目录下运行。您应该克隆存储库,并将要构建的Dockerfile移至根目录,然后再次构建。