【问题标题】:LUIS mount pointsLUIS 挂载点
【发布时间】:2019-11-14 20:58:19
【问题描述】:

我正在尝试使用自定义 Dockerfile 来构建 LUIS 容器并将应用程序文件(从 Luis 门户导出的应用程序)复制到容器中。出于这个原因,我真的不需要挂载点,因为 .gz 文件已经存在于容器中。这可能吗?似乎总是需要挂载点...

我必须将文件复制到容器中并在运行时将它们移动到input 位置(使用 init.sh 脚本)。但是,即便如此,容器似乎也无法正确加载应用程序。与仅将文件放入主机文件夹并将其挂载到容器相比,它的行为与该场景不同。

更新:当我尝试在内部(在容器的开头)移动文件时,LUIS 会给出以下输出:

Using '/input' for reading models and other read-only data.
Using '/output/luis/fbfb798892fd' for writing logs and other output data.
Logging to console.
Submitting metering to 'https://southcentralus.api.cognitive.microsoft.com/'.
warn: Microsoft.AspNetCore.Server.Kestrel[0]
      Overriding address(es) 'http://+:80'. Binding to endpoints defined in UseKestrel() instead.
Hosting environment: Production
Content root path: /app
Now listening on: http://0.0.0.0:5000
Application started. Press Ctrl+C to shut down.
fail: Luis[0]
      Failed while prefetching App: AppId: d6fa5fd3-c32a-44d5-bb7f-d563775cf6ee - Slot: PRODUCTION Could not find file '/input/d6fa5fd3-c32a-44d5-bb7f-d563775cf6ee_PRODUCTION.gz'.
fail: Luis[0]
      Failed while getting response for AppId: d6fa5fd3-c32a-44d5-bb7f-d563775cf6ee - Slot: PRODUCTION. Error: Could not find file '/input/d6fa5fd3-c32a-44d5-bb7f-d563775cf6ee_PRODUCTION.gz'.
warn: Microsoft.CloudAI.Containers.Controllers.LuisControllerV3[0]
      Response status code: 404
      Exception: Could not find file '/input/d6fa5fd3-c32a-44d5-bb7f-d563775cf6ee_PRODUCTION.gz'. SubscriptionId='' RequestId='d7dfee25-05d9-4af6-804d-58558f55465e' Timestamp=''
^C
nuc@nuc-NUC8i7BEK:/tmp/input$ sudo docker exec -it luis bash
root@fbfb798892fd:/app# cd /input
root@fbfb798892fd:/input# ls
d6fa5fd3-c32a-44d5-bb7f-d563775cf6ee_production.gz
root@fbfb798892fd:/input# ls -l
total 8
-rwxrwxrwx 1 root root 4960 Dec  2 17:35 d6fa5fd3-c32a-44d5-bb7f-d563775cf6ee_production.gz
root@fbfb798892fd:/input# 

请注意,即使我可以登录到容器并浏览模型文件的位置并且它们存在,LUIS 也无法加载/找到它们。

更新 #2 - 发布我的 Dockerfile:

FROM mcr.microsoft.com/azure-cognitive-services/luis:latest

ENV Eula=accept
ENV Billing=https://southcentralus.api.cognitive.microsoft.com/
ENV ApiKey=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ENV Logging:Console:LogLevel:Default=Debug

RUN mkdir /app/inputfiles/
RUN chmod 777 /app/inputfiles/
COPY *.gz /app/inputfiles/

WORKDIR /app

COPY init.sh .
RUN chmod 777 /app/init.sh

ENTRYPOINT /app/init.sh && dotnet Microsoft.CloudAI.Containers.Luis.dll

【问题讨论】:

  • 您是说您正在尝试构建您自己的 mcr.microsoft.com/azure-cognitive-services/luis 映像版本,其中包含您导出的 .gz 文件吗?你希望通过这样做来实现什么?
  • 你还在做这个吗?
  • 我发现这个问题没有解决方法。我很想知道绕过这个约束的方法。但是,我在当前容器中看不到一个。所以,是的,这仍然是一个问题,但我现在正在按照它需要的方式提交。
  • 您的init.sh 文件是什么样的?此外,容器指的是 /input 并且您的文件被复制到 /inputfiles - 这有关系吗?
  • @DavidPine - 是的,.gz 文件需要复制到 /input 而不是 /app/inputFiles 才能正常工作

标签: docker dockerfile containers azure-language-understanding azure-cognitive-services


【解决方案1】:

选项 1

模型可以COPY'd 直接进入/input/。 例如

FROM mcr.microsoft.com/azure-cognitive-services/luis:latest

COPY *.gz /input/

这可行,但要求您不要在运行时挂载到 /input,因为它会压缩 COPY'd 文件。仅当/input 目录不存在时才会记录消息“必须安装文件夹”。

 > docker build . -t luis --no-cache
Sending build context to Docker daemon  40.43MB
Step 1/2 : FROM aicpppe.azurecr.io/microsoft/cognitive-services-luis
 ---> df4e32e45b1e
Step 2/2 : COPY ./*.gz /input/
 ---> c5f41a9d8522
Successfully built c5f41a9d8522
Successfully tagged luis:latest

> docker run --rm -it -p 5000:5000 luis eula=accept billing=*** apikey=***
...
Using '/input' for reading models and other read-only data.
...
Application started. Press Ctrl+C to shut down.

选项 2

可以设置配置值Mounts:Input来配置输入位置。

如果您需要模型在/app/inputfiles 中运行,或者如果您在运行时出于其他原因需要挂载到/input,这可能会很有用。

例如

FROM aicpppe.azurecr.io/microsoft/cognitive-services-luis

ENV Mounts:Input=/app/inputfiles
COPY ./*.gz /app/inputfiles/

这会导致:

 > docker build . -t luis --no-cache
Sending build context to Docker daemon  40.43MB
Step 1/3 : FROM aicpppe.azurecr.io/microsoft/cognitive-services-luis
 ---> df4e32e45b1e
Step 2/3 : ENV Mounts:Input=/app/inputfiles
 ---> Running in b6029a2b54d0
Removing intermediate container b6029a2b54d0
 ---> cb9a4e06463b
Step 3/3 : COPY ./*.gz /app/inputfiles/
 ---> 9ab1dfaa36e7
Successfully built 9ab1dfaa36e7
Successfully tagged luis:latest

 > docker run --rm -it -p 5000:5000 luis eula=accept billing=*** apikey=***
...
Using '/app/inputfiles' for reading models and other read-only data.
...
Application started. Press Ctrl+C to shut down.

【讨论】:

    【解决方案2】:

    如果您的 .gz 文件已经在映像中,则输入挂载确实不是必需的,但输出挂载用于 logging,您可能仍希望将其用于主动学习。

    要构建所需的映像,请创建一个名为 Dockerfile 的文本文件(无扩展名)并使用以下行填充它:

    FROM mcr.microsoft.com/azure-cognitive-services/luis:latest
    
    ENV Eula=accept
    ENV Billing={ENDPOINT_URI}
    ENV ApiKey={API_KEY}
    
    COPY ./{luisAppId}_PRODUCTION.gz /input/{luisAppId}_PRODUCTION.gz
    

    您可以使用普通的LUIS container instructions 找到您的{ENDPOINT_URI}{API_KEY},当然{luisAppId} 将在您的.gz 文件的名称中找到。一旦您的 Dockerfile 准备就绪,请使用以下命令从包含 .gz 文件的同一文件夹中运行它:

    docker build -t luis .
    

    您的图像现在就准备好了。你的队友所要做的就是运行这个命令:

    docker run --rm -it -p 5000:5000
      --memory 4g
      --cpus 2
      --mount type=bind,src={OUTPUT_FOLDER},target=/output luis
    

    {OUTPUT_FOLDER} 可以是您想要的任何本地绝对路径,只要它存在即可。如果您不想要任何日志记录,您也可以省略输出挂载:

    docker run --rm -it -p 5000:5000 --memory 4g --cpus 2 luis
    

    【讨论】:

    • 是的——我已经试过了。它不起作用。顺便说一句,我只是要求将挂载点设为可选,但就目前而言,它们是必需的。原因以及您的解决方案不起作用的原因是,当您使用 dockerfile 复制文件时,这是在构建时。挂载点发生在运行时。挂载点会覆盖在构建时复制的内部文件。此外,我什至测试了一个在运行时运行并在容器启动后复制文件的解决方案。这也行不通。唯一可行的解​​决方案是挂载点。
    • @runninggeek - 当你在 Stack Overflow 上提问时,你应该对你已经尝试过的内容提供一个全面的解释
    • @runninggeek - 你能解释一下究竟是什么“不起作用”,以便我可以帮助你使它起作用吗?如果您编辑您的问题以包含您制作的 Dockerfile 以及您用于构建和运行它的命令,这将有所帮助。两个挂载点都已经是可选的,我解释说我只包括输出挂载点以用于日志记录。如果您愿意,您可以省略两个挂载点,但您绝对应该省略输入挂载点(如我所示),因为它仅用于将 .gz 文件放入容器的输入文件夹,这里的 Dockerfile 已经这样做了.
    • 当我说“不起作用”时,我的意思是 LUIS 应用程序没有正确加载模型。我不确定问题出在哪里,但是当我将文件放在主机文件夹中与尝试在容器启动时复制它们时,行为会有所不同。
    • 查看我在原始问题中发布的更新输出。它显示了我尝试在容器内移动文件时的行为。
    猜你喜欢
    • 2020-02-19
    • 2013-10-31
    • 1970-01-01
    • 2017-06-23
    • 1970-01-01
    • 2017-04-22
    • 1970-01-01
    • 2022-12-18
    • 2021-07-03
    相关资源
    最近更新 更多