Files
rocm-automated/Dockerfiles/Dockerfile.stable-diffusion.cpp-rocm7.1
2026-01-05 16:05:32 -05:00

71 lines
2.1 KiB
Docker

FROM rocm/dev-ubuntu-24.04:7.1-complete AS builder
# vim: filetype=dockerfile
ARG GFX_NAME=gfx1151
RUN apt-get update \
&& apt-get install -y ca-certificates libvulkan1 git cmake ninja-build clang \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Clone and build stable-diffusion.cpp
RUN git clone https://github.com/leejet/stable-diffusion.cpp /stable-diffusion.cpp
WORKDIR /stable-diffusion.cpp
RUN git pull origin master && \
git submodule init && \
git submodule update
RUN mkdir -p build && cd build && \
cmake .. -G "Ninja" \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DSD_HIPBLAS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DGPU_TARGETS=$GFX_NAME \
-DAMDGPU_TARGETS=$GFX_NAME \
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON && \
cmake --build . --config Release
# Clone sd.cpp-webui and place the binary in its folder as per instructions
WORKDIR /
RUN git clone https://github.com/daniandtheweb/sd.cpp-webui.git /sd-webui
WORKDIR /sd-webui
# Copy the compiled sd binary to the webui folder as required
RUN cp /stable-diffusion.cpp/build/bin/sd-cli /sd-webui/sd-cli
RUN cp /stable-diffusion.cpp/build/bin/sd-server /sd-webui/sd-server
# Make the launch script executable
RUN chmod +x sdcpp_webui.sh
# Runtime stage
FROM rocm/dev-ubuntu-24.04:7.1-complete AS runtime
RUN apt install -y python3
#RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.13 100
#RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.13 100
# Create video group and add proper permissions
RUN groupadd -g 44 video || true
# Copy the complete sd-webui with the binary and installed dependencies
COPY --from=builder /sd-webui /sd-webui
# Set up library paths and working directory
WORKDIR /sd-webui
# Create directories for models and outputs
RUN mkdir -p /sd-webui/models /sd-webui/outputs
WORKDIR /sd-webui
# Expose web UI port
EXPOSE 7860
# Add startup script that follows the official instructions
ENTRYPOINT ["./sdcpp_webui.sh", "--autostart", "--listen"]