我正在尝试使用自定义的 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
答案 0 :(得分:1)
如果您的.gz文件已经在映像中,则确实不需要输入安装,但是输出安装用于logging,并且您可能仍希望将其用于主动学习。
要构建所需的图像,请创建一个名为 Dockerfile 的文本文件(无扩展名),并使用以下几行进行填充:
const newData = {
id: 1,
url: "url",
query: "mangoes",
title: "this title"
}
const target = [
{
id: 0,
url: "",
query: "mangoes",
title: "old title"
}
]
const switchCase = () => {
return {
targetProp: target.splice(0, 1, newData)
}
}
您可以使用常规的{ENDPOINT_URI}
找到{API_KEY}
和LUIS container instructions,当然,您会在.gz文件的名称中找到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
。准备好 Dockerfile 之后,使用以下命令从包含.gz文件的同一文件夹中运行它:
{luisAppId}
您的图像现在可以使用了。您的队友要做的就是运行以下命令:
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}
答案 1 :(得分:1)
可以COPY
直接将模型放入/input/
中。
例如
FROM mcr.microsoft.com/azure-cognitive-services/luis:latest
COPY *.gz /input/
这将起作用,但是要求您不要在运行时安装到/ input ,因为它将压缩COPY
文件。仅当/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.
可以设置配置值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.