Michael Rabinovich commited on
Commit
ba9a513
·
1 Parent(s): be11b5a

dockerfile: isolate Python deps in venv

Browse files
Files changed (1) hide show
  1. Dockerfile +7 -6
Dockerfile CHANGED
@@ -18,6 +18,8 @@ FROM nvidia/cuda:12.4.1-runtime-ubuntu22.04
18
  ENV PYTHONUNBUFFERED=1 \
19
  PYTHONDONTWRITEBYTECODE=1 \
20
  PIP_DISABLE_PIP_VERSION_CHECK=1 \
 
 
21
  DEBIAN_FRONTEND=noninteractive
22
 
23
  # Python 3.12 from deadsnakes (Ubuntu 22.04 ships 3.10 by default)
@@ -37,12 +39,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
37
  && ln -sf /usr/bin/python3.12 /usr/local/bin/python \
38
  && ln -sf /usr/bin/python3.12 /usr/local/bin/python3
39
 
40
- # Bootstrap pip for Python 3.12. Ubuntu 22.04's apt `python3-pip`
41
- # is built against the system Python 3.10 and depends on the
42
- # `distutils` module that 3.12 removed; invoking it under 3.12
43
- # raises ModuleNotFoundError: distutils. ensurepip ships with the
44
- # 3.12 stdlib and gives us a matching pip.
45
- RUN python -m ensurepip --upgrade \
46
  && python -m pip install --no-cache-dir --upgrade pip
47
 
48
  # cadgenbench from the Public GitHub repo, same convention and ARG name
 
18
  ENV PYTHONUNBUFFERED=1 \
19
  PYTHONDONTWRITEBYTECODE=1 \
20
  PIP_DISABLE_PIP_VERSION_CHECK=1 \
21
+ VIRTUAL_ENV=/opt/venv \
22
+ PATH="/opt/venv/bin:$PATH" \
23
  DEBIAN_FRONTEND=noninteractive
24
 
25
  # Python 3.12 from deadsnakes (Ubuntu 22.04 ships 3.10 by default)
 
39
  && ln -sf /usr/bin/python3.12 /usr/local/bin/python \
40
  && ln -sf /usr/bin/python3.12 /usr/local/bin/python3
41
 
42
+ # Build the runtime Python environment in a venv. The CUDA/deadsnakes
43
+ # apt setup leaves distro Python modules (for example blinker) on the
44
+ # system path; isolating pip installs avoids trying to uninstall
45
+ # apt-owned distutils packages during dependency resolution.
46
+ RUN python -m venv "$VIRTUAL_ENV" \
 
47
  && python -m pip install --no-cache-dir --upgrade pip
48
 
49
  # cadgenbench from the Public GitHub repo, same convention and ARG name