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

时间:2024-12-09 20:36:09

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_lora_train.sh /home/ma-user/sdxl-train/user-job-dir/code/diffusers_lora_train.sh
COPY --chown=ma-user:ma-group train_text_to_image_lora_sdxl-0212.py /home/ma-user/sdxl-train/user-job-dir/code/train_text_to_image_lora_sdxl-0212.py
COPY --chown=ma-user:ma-group npu_attention_processor.py /home/ma-user/sdxl-train/user-job-dir/code/npu_attention_processor.py

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
support.huaweicloud.com/bestpractice-modelarts/modelarts_10_01202.html