LUIS 挂载点

LUIS mount points

我正在尝试使用自定义 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 也无法 load/find 它们。

更新 #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

确实,如果您的 .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

您可以找到您的 {ENDPOINT_URI} and your {API_KEY} using the normal LUIS container instructions,当然,{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

选项 1

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

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

COPY *.gz /input/

这会起作用,但要求您不要在运行时挂载到 /input,因为它会压缩 COPY 的文件。仅当 /input 目录不存在时才会记录消息 "A folder must be mounted"。

 > 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.