Skip to content

Commit

Permalink
try using copying dependencies to a known place, then symlink to wher…
Browse files Browse the repository at this point in the history
…eever pyenv actually is

Signed-off-by: technillogue <[email protected]>
  • Loading branch information
technillogue committed Aug 30, 2023
1 parent 2111ad5 commit 01a08b7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
12 changes: 10 additions & 2 deletions pkg/dockerfile/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,16 @@ func (g *Generator) pipInstalls() string {
// placing packages in workdir makes imports faster but seems to break integration tests
// return "COPY --from=deps --link /dep COPY --from=deps /src"
// ...except it's actually /root/.pyenv/versions/3.8.17/lib/python3.8/site-packages
target := g.sitePackagesLocation()
return "COPY --from=deps --link /dep " + target
py := g.Config.Build.PythonVersion
if g.Config.Build.GPU && g.useCudaBaseImage {
return strings.Join(
[]string{
"COPY --from=deps --link /dep /dep",
"RUN ln -s /dep/* $(pyenv prefix)/lib/python*/site-packages",
},
"\n")
}
return "COPY --from=deps --link /dep /usr/local/lib/python" + py + "/site-packages"
}

func (g *Generator) runCommands() (string, error) {
Expand Down
9 changes: 6 additions & 3 deletions pkg/dockerfile/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu:/usr/local/nvidia/lib64:/usr/local/nvidia/bin
` + testTini() + testInstallPython("3.8") + `COPY --from=deps --link /dep /root/.pyenv/versions/3.8.18/lib/python3.8/site-packages
` + testTini() + testInstallPython("3.8") + `COPY --from=deps --link /dep /dep
RUN ln -s /dep/* $(pyenv prefix)/lib/python*/site-packages
WORKDIR /src
EXPOSE 5000
CMD ["python", "-m", "cog.server.http"]
Expand Down Expand Up @@ -213,7 +214,8 @@ ENV PYTHONUNBUFFERED=1
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu:/usr/local/nvidia/lib64:/usr/local/nvidia/bin
` + testTini() +
testInstallPython("3.8") + `RUN --mount=type=cache,target=/var/cache/apt apt-get update -qq && apt-get install -qqy ffmpeg cowsay && rm -rf /var/lib/apt/lists/*
COPY --from=deps --link /dep /root/.pyenv/versions/3.8.18/lib/python3.8/site-packages
COPY --from=deps --link /dep /dep
RUN ln -s /dep/* $(pyenv prefix)/lib/python*/site-packages
RUN cowsay moo
WORKDIR /src
EXPOSE 5000
Expand Down Expand Up @@ -364,7 +366,8 @@ ENV PYTHONUNBUFFERED=1
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu:/usr/local/nvidia/lib64:/usr/local/nvidia/bin
` + testTini() +
testInstallPython("3.8") + `RUN --mount=type=cache,target=/var/cache/apt apt-get update -qq && apt-get install -qqy ffmpeg cowsay && rm -rf /var/lib/apt/lists/*
COPY --from=deps --link /dep /root/.pyenv/versions/3.8.18/lib/python3.8/site-packages
COPY --from=deps --link /dep /dep
RUN ln -s /dep/* $(pyenv prefix)/lib/python*/site-packages
RUN cowsay moo
COPY --from=weights --link /src/checkpoints /src/checkpoints
COPY --from=weights --link /src/models /src/models
Expand Down

0 comments on commit 01a08b7

Please sign in to comment.