rocm.Dockerfile 3.1 KB

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