1
0

rocm.Dockerfile 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. ARG UBUNTU_VERSION=24.04
  2. # This needs to generally match the container host's environment.
  3. ARG ROCM_VERSION=7.0
  4. ARG AMDGPU_VERSION=7.0
  5. # Target the ROCm build image
  6. ARG BASE_ROCM_DEV_CONTAINER=rocm/dev-ubuntu-${UBUNTU_VERSION}:${ROCM_VERSION}-complete
  7. ### Build image
  8. FROM ${BASE_ROCM_DEV_CONTAINER} AS build
  9. # Unless otherwise specified, we make a fat build.
  10. # List from https://github.com/ggml-org/llama.cpp/pull/1087#issuecomment-1682807878
  11. # This is mostly tied to rocBLAS supported archs.
  12. # gfx803, gfx900, gfx906, gfx1032, gfx1101, gfx1102,not officialy supported
  13. # check https://rocm.docs.amd.com/projects/install-on-linux/en/docs-6.4.1/reference/system-requirements.html
  14. ARG ROCM_DOCKER_ARCH='gfx803;gfx900;gfx906;gfx908;gfx90a;gfx942;gfx1010;gfx1030;gfx1032;gfx1100;gfx1101;gfx1102;gfx1200;gfx1201;gfx1151'
  15. #ARG ROCM_DOCKER_ARCH='gfx1151'
  16. # Set ROCm architectures
  17. ENV AMDGPU_TARGETS=${ROCM_DOCKER_ARCH}
  18. RUN apt-get update \
  19. && apt-get install -y \
  20. build-essential \
  21. cmake \
  22. git \
  23. libcurl4-openssl-dev \
  24. curl \
  25. libgomp1
  26. WORKDIR /app
  27. COPY . .
  28. RUN HIPCXX="$(hipconfig -l)/clang" HIP_PATH="$(hipconfig -R)" \
  29. cmake -S . -B build \
  30. -DGGML_HIP=ON \
  31. -DGGML_HIP_ROCWMMA_FATTN=ON \
  32. -DAMDGPU_TARGETS="$ROCM_DOCKER_ARCH" \
  33. -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON \
  34. -DCMAKE_BUILD_TYPE=Release -DLLAMA_BUILD_TESTS=OFF \
  35. && cmake --build build --config Release -j$(nproc)
  36. RUN mkdir -p /app/lib \
  37. && find build -name "*.so*" -exec cp -P {} /app/lib \;
  38. RUN mkdir -p /app/full \
  39. && cp build/bin/* /app/full \
  40. && cp *.py /app/full \
  41. && cp -r gguf-py /app/full \
  42. && cp -r requirements /app/full \
  43. && cp requirements.txt /app/full \
  44. && cp .devops/tools.sh /app/full/tools.sh
  45. ## Base image
  46. FROM ${BASE_ROCM_DEV_CONTAINER} AS base
  47. RUN apt-get update \
  48. && apt-get install -y libgomp1 curl\
  49. && apt autoremove -y \
  50. && apt clean -y \
  51. && rm -rf /tmp/* /var/tmp/* \
  52. && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \
  53. && find /var/cache -type f -delete
  54. COPY --from=build /app/lib/ /app
  55. ### Full
  56. FROM base AS full
  57. COPY --from=build /app/full /app
  58. WORKDIR /app
  59. RUN apt-get update \
  60. && apt-get install -y \
  61. git \
  62. python3-pip \
  63. python3 \
  64. python3-wheel\
  65. && pip install --break-system-packages --upgrade setuptools \
  66. && pip install --break-system-packages -r requirements.txt \
  67. && apt autoremove -y \
  68. && apt clean -y \
  69. && rm -rf /tmp/* /var/tmp/* \
  70. && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \
  71. && find /var/cache -type f -delete
  72. ENTRYPOINT ["/app/tools.sh"]
  73. ### Light, CLI only
  74. FROM base AS light
  75. COPY --from=build /app/full/llama-cli /app
  76. WORKDIR /app
  77. ENTRYPOINT [ "/app/llama-cli" ]
  78. ### Server, Server only
  79. FROM base AS server
  80. ENV LLAMA_ARG_HOST=0.0.0.0
  81. COPY --from=build /app/full/llama-server /app
  82. WORKDIR /app
  83. HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ]
  84. ENTRYPOINT [ "/app/llama-server" ]