Dockerfile.cpu 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # This Aphrodite Dockerfile is used to construct image that can build and run Aphrodite on x86 CPU platform.
  2. FROM ubuntu:22.04 AS cpu-test-1
  3. ENV CCACHE_DIR=/root/.cache/ccache
  4. ENV CMAKE_CXX_COMPILER_LAUNCHER=ccache
  5. RUN --mount=type=cache,target=/var/cache/apt \
  6. apt-get update -y \
  7. && apt-get install -y curl ccache git wget vim numactl gcc-12 g++-12 python3 python3-pip libtcmalloc-minimal4 libnuma-dev \
  8. && apt-get install -y ffmpeg libsm6 libxext6 libgl1 \
  9. && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 10 --slave /usr/bin/g++ g++ /usr/bin/g++-12
  10. # https://intel.github.io/intel-extension-for-pytorch/cpu/latest/tutorials/performance_tuning/tuning_guide.html
  11. # intel-openmp provides additional performance improvement vs. openmp
  12. # tcmalloc provides better memory allocation efficiency, e.g, holding memory in caches to speed up access of commonly-used objects.
  13. RUN --mount=type=cache,target=/root/.cache/pip \
  14. pip install intel-openmp
  15. ENV LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libtcmalloc_minimal.so.4:/usr/local/lib/libiomp5.so"
  16. RUN echo 'ulimit -c 0' >> ~/.bashrc
  17. RUN pip install https://intel-extension-for-pytorch.s3.amazonaws.com/ipex_dev/cpu/intel_extension_for_pytorch-2.4.0%2Bgitfbaa4bc-cp310-cp310-linux_x86_64.whl
  18. ENV PIP_EXTRA_INDEX_URL=https://download.pytorch.org/whl/cpu
  19. RUN --mount=type=cache,target=/root/.cache/pip \
  20. --mount=type=bind,src=requirements-build.txt,target=requirements-build.txt \
  21. pip install --upgrade pip && \
  22. pip install -r requirements-build.txt
  23. # install oneDNN
  24. RUN git clone -b rls-v3.5 https://github.com/oneapi-src/oneDNN.git
  25. RUN --mount=type=cache,target=/root/.cache/ccache \
  26. cmake -B ./oneDNN/build -S ./oneDNN -G Ninja -DONEDNN_LIBRARY_TYPE=STATIC \
  27. -DONEDNN_BUILD_DOC=OFF \
  28. -DONEDNN_BUILD_EXAMPLES=OFF \
  29. -DONEDNN_BUILD_TESTS=OFF \
  30. -DONEDNN_BUILD_GRAPH=OFF \
  31. -DONEDNN_ENABLE_WORKLOAD=INFERENCE \
  32. -DONEDNN_ENABLE_PRIMITIVE=MATMUL && \
  33. cmake --build ./oneDNN/build --target install --config Release
  34. FROM cpu-test-1 AS build
  35. WORKDIR /workspace/aphrodite-engine
  36. RUN --mount=type=cache,target=/root/.cache/pip \
  37. --mount=type=bind,src=requirements-common.txt,target=requirements-common.txt \
  38. --mount=type=bind,src=requirements-cpu.txt,target=requirements-cpu.txt \
  39. pip install -v -r requirements-cpu.txt
  40. COPY ./ ./
  41. # Support for building with non-AVX512 Aphrodite: docker build --build-arg APHRODITE_CPU_DISABLE_AVX512="true" ...
  42. ARG APHRODITE_CPU_DISABLE_AVX512
  43. ENV APHRODITE_CPU_DISABLE_AVX512=${APHRODITE_CPU_DISABLE_AVX512}
  44. RUN --mount=type=cache,target=/root/.cache/pip \
  45. --mount=type=cache,target=/root/.cache/ccache \
  46. APHRODITE_TARGET_DEVICE=cpu python3 setup.py bdist_wheel && \
  47. pip install dist/*.whl
  48. WORKDIR /workspace/
  49. RUN ln -s /workspace/aphrodite-engine/tests && ln -s /workspace/aphrodite-engine/examples && ln -s /workspace/aphrodite-engine/benchmarks
  50. ENTRYPOINT ["python3", "-m", "aphrodite.entrypoints.openai.api_server"]