Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions docker/Dockerfile.rocm
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
FROM rocm/dev-ubuntu-24.04 AS build

# sd-server embeds the web UI at build time, so the build image needs Node/pnpm.
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential git cmake ninja-build ccache ca-certificates curl gnupg && \
mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key -o /tmp/nodesource-repo.gpg.key && \
gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg /tmp/nodesource-repo.gpg.key && \
rm /tmp/nodesource-repo.gpg.key && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" > /etc/apt/sources.list.d/nodesource.list && \
apt-get update && apt-get install -y --no-install-recommends nodejs && \
npm install -g pnpm@10.15.1 && \
apt-get clean && rm -rf /var/lib/apt/lists/*

WORKDIR /sd.cpp

# ROCm's clang is not on PATH in Docker RUN shells (profile scripts are not loaded).
ENV PATH="/opt/rocm/llvm/bin:$PATH"

COPY . .

ARG AMDGPU_TARGETS=gfx1100

RUN cmake . -B ./build -G Ninja \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DSD_HIPBLAS=ON \
-DAMDGPU_TARGETS=${AMDGPU_TARGETS} \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
RUN cmake --build ./build --config Release --parallel

FROM rocm/dev-ubuntu-24.04 AS runtime

# ROCm clang links against its own OpenMP runtime in /opt/rocm/llvm/lib,
# and the ROCm runtime libs (hipblas, rocblas, amdhip64) live in /opt/rocm/lib.
ENV LD_LIBRARY_PATH="/opt/rocm/llvm/lib:/opt/rocm/lib:$LD_LIBRARY_PATH"

RUN apt-get update && \
apt-get install --yes --no-install-recommends libgomp1 && \
apt-get clean && rm -rf /var/lib/apt/lists/*

COPY --from=build /sd.cpp/build/bin /sd.cpp/bin
RUN printf '#!/bin/sh\nexec /sd.cpp/bin/sd-cli "$@"\n' > /sd-cli && \
printf '#!/bin/sh\nexec /sd.cpp/bin/sd-server "$@"\n' > /sd-server && \
chmod +x /sd-cli /sd-server

ENTRYPOINT [ "/sd-cli" ]
6 changes: 6 additions & 0 deletions docs/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ Vulkan:
docker build -f docker/Dockerfile.vulkan -t sd .
```

ROCm (AMD GPU):

```shell
docker build -f docker/Dockerfile.rocm --build-arg AMDGPU_TARGETS=gfx1100 -t sd .
```

## Run locally built image's CLI

```shell
Expand Down