rocm.Dockerfile 2.9 KB

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