英文:
Multi-stage build with Nvidia container
问题
我想使用 Docker 多阶段构建来压缩一个 Docker 镜像。我的 Dockerfile 大致如下:
FROM nvcr.io/nvidia/l4t-tensorrt:r8.2.1-runtime as build
# ...
FROM scratch
COPY --from=build / /
CMD ["/bin/bash"]
然而,如果我尝试运行这个镜像(即使使用 --runtime nvidia
),Nvidia 库在运行时不会被挂载。我该如何处理?
英文:
I would like to flatten a docker image by using docker multi-stage. My Dockerfile is something like this:
FROM nvcr.io/nvidia/l4t-tensorrt:r8.2.1-runtime as build
# ...
FROM scratch
COPY --from=build / /
CMD ["/bin/bash"]
However if I try to run this image (even if I use --runtime nvidia
), the Nvidia libraries will not be mounted at runtime. How can I do it?
答案1
得分: 0
我通过在最新的阶段添加ENV
指令来解决了这个问题。可以使用docker inspect nvcr.io/nvidia/l4t-tensorrt:r8.2.1-runtime
来检索这些变量。
英文:
I solved by adding ENV
instruction to the latest stage. The variables can be retrieved with docker inspect nvcr.io/nvidia/l4t-tensorrt:r8.2.1-runtime
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论