Multi-stage build with Nvidia container: 多阶段构建与Nvidia容器

huangapple go评论58阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年6月29日 20:19:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76581002.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定