AI开发平台MODELARTS-SDXL基于DevServer适配PyTorch NPU的Finetune训练指导(6.3.905):Step3 构建镜像

时间:2025-01-03 09:38:41

Step3 构建镜像

基于官方提供的基础镜像构建 自定义镜像 sdxl-train:0.0.1。参考如下命令编写Dockerfile文件。镜像地址{image_url}请参见表2

FROM {image_url}

RUN mkdir /home/ma-user/sdxl-train && mkdir /home/ma-user/sdxl-train/user-job-dir && mkdir /home/ma-user/sdxl-train/user-job-dir/code
COPY --chown=ma-user:ma-group diffusers_finetune_train.sh /home/ma-user/sdxl-train/user-job-dir/code/diffusers_finetune_train.sh
COPY --chown=ma-user:ma-group train_text_to_image_sdxl-0212.py /home/ma-user/sdxl-train/user-job-dir/code/train_text_to_image_sdxl-0212.py
COPY --chown=ma-user:ma-group config.yaml /home/ma-user/sdxl-train/user-job-dir/code/config.yaml

COPY --chown=ma-user:ma-group stable-diffusion-xl-base-1.0 /home/ma-user/sdxl-train/stable-diffusion-xl-base-1.0
COPY --chown=ma-user:ma-group vae-fp16-fix /home/ma-user/sdxl-train/vae-fp16-fix
COPY --chown=ma-user:ma-group datasets /home/ma-user/sdxl-train/datasets

RUN pip install  accelerate datasets transformers diffusers
RUN source /etc/bashrc && pip install  deepspeed
COPY --chown=ma-user:ma-group attention_processor.py /home/ma-user/anaconda3/envs/PyTorch-2.1.0/lib/python3.9/site-packages/diffusers/models/attention_processor.py
support.huaweicloud.com/bestpractice-modelarts/modelarts_10_01201.html