探索新一代图像生成:Stable Diffusion ROCm Docker
# 使用AMD ROCm支持的Stable Diffusion环境
FROM rocm/dev-ubuntu:20.10
# 设置环境变量
ENV ROCM_VERSION 5.1.0
ENV ROCM_GPU_ENABLED 0
ENV PATH /opt/rocm/bin:/opt/rocm/profiler/bin:$PATH
ENV LD_LIBRARY_PATH /opt/rocm/lib:/opt/rocm/lib64
ENV PYTORCH_VERSION 1.11.0
ENV CUDA_VERSION 11.3.0
ENV CMAKE_VERSION 3.23.0
ENV NCCL_VERSION 2.13.7
ENV NVIDIA_REQUIRE_CUDA "cuda>=11.2"
# 安装ROCm工具和依赖
RUN apt-get update && apt-get install -y --no-install-recommends \
g++ \
git \
libnuma-dev \
libssl-dev \
make \
wget \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# 下载并安装ROCm
RUN wget https://repo.radeon.com/rocm/rocm-${ROCM_VERSION}/rocm-${ROCM_VERSION}.tar.gz && \
tar -xz --strip-components=1 -f rocm-${ROCM_VERSION}.tar.gz && \
rm -f rocm-${ROCM_VERSION}.tar.gz && \
./install.sh --no-news && \
echo 'export PATH=/opt/rocm/bin:/opt/rocm/profiler/bin:$PATH' >> ~/.bashrc && \
echo 'export LD_LIBRARY_PATH=/opt/rocm/lib:/opt/rocm/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc && \
source ~/.bashrc
# 安装Python和pip
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 \
python3-pip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# 更新pip到最新版本
RUN pip3 install --upgrade pip
# 安装PyTorch
RUN pip3 install torch==$PYTORCH_VERSION+rocm$ROCM_VERSION -f https://download.pytorch.org/whl/rocm/$ROCM_VERSION/torch_stable.html
# 安装其他依赖
RUN pip3 install numpy cmake numba llvmlite torchvision torchaudio --extra-index-url https://rocm.pytorch.org
# 克隆Stable Diffus
评论已关闭