Compare commits

...

13 Commits

Author SHA1 Message Date
zhousha
c4e1c9c1b1 update Dockerfile and Readme 2025-09-19 10:21:40 +08:00
ec1bc21667 mount current dir to /workspace 2025-08-28 17:53:55 +08:00
d5e9c0c27c 更新 Dockerfile 2025-08-28 17:31:23 +08:00
611281896d remove uncessary files and update readme 2025-08-26 21:46:07 +08:00
be947dfc79 update readme 2025-08-26 18:13:06 +08:00
fcf7f30797 update base image of a100 2025-08-26 17:31:39 +08:00
b9906fa791 change base image for mlu370 2025-08-26 17:25:25 +08:00
root
ce8d16c160 update run_in_docker_mlu370 scripts 2025-08-26 15:35:32 +08:00
b524f25741 support mlu370 2025-08-25 17:07:12 +08:00
4d35251531 add README 2025-08-25 14:14:19 +08:00
931a35a7db change base image 2025-08-25 14:01:43 +08:00
c1f0819f82 update test.sh 2025-08-21 11:16:11 +08:00
ef778f63e0 add Dockerfile for A100 2025-08-21 11:00:53 +08:00
7 changed files with 32 additions and 35 deletions

View File

@@ -1,6 +1,8 @@
FROM zibo.harbor.iluvatar.com.cn:30000/saas/bi100-3.2.1-x86-ubuntu20.04-py3.10-poc-llm-infer:v1.2.2 FROM mlu370-pytorch:v25.01-torch2.5.0-torchmlu1.24.1-ubuntu22.04-py310
WORKDIR /workspace WORKDIR /workspace
ENV PT_SDPA_ENABLE_HEAD_DIM_PADDING=1 ENV PATH=/torch/venv3/pytorch_infer/bin:/workspace/ffmpeg-mlu-v4.2.0/install/bin:/usr/local/neuware/bin:/usr/local/openmpi/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
RUN pip install diffusers==0.34.0 RUN pip install diffusers==0.34.0
COPY main.py test.sh dataset.json /workspace/ RUN sed -i 's|source /torch/venv3/pytorch/bin/activate|source /torch/venv3/pytorch_infer/bin/activate|' /root/.bashrc
COPY main.py dataset.json /workspace/

View File

@@ -1,7 +0,0 @@
FROM corex:4.3.0
WORKDIR /workspace
COPY whls-mrv100 /packages
RUN pip install diffusers==0.34.0 sentencepiece transformers==4.55.2
# RUN pip install /packages/*.whl
COPY main.py test.sh dataset.json /workspace/

24
README.md Normal file
View File

@@ -0,0 +1,24 @@
## Quickstart
### 构建镜像
```bash
docker build -t diffusers:v0.1 .
```
其中基础镜像 mlu370-pytorch:v25.01-torch2.5.0-torchmlu1.24.1-ubuntu22.04-py310 联系寒武纪厂商技术支持可获取
### 模型下载
模型地址https://modelscope.cn/models/AI-ModelScope/stable-diffusion-v1-5
并放到目录:`/mnt/contest_ceph/zhanghao/models/stable-diffusion-v1-5`(如更改目录,请修改后面的执行脚本中的模型路径)
### 测试程序
1. 准备输入数据集,可以参考示例`dataset.json`
2. 在docker镜像里运行测试程序会根据`dataset.json`内容,在`output`目录下生成图片文件。
```bash
./run_in_docker.sh
```
## 测试结果
| | A100 平均生成时间(秒) | MLU370-x4 平均生成时间(秒) | MLU370-x8 平均生成时间(秒) |
|------|-------------------------|----------------------------|----------------------------|
| 时间 | 1.5 | 4.2 | 5.3 |

View File

@@ -1,3 +1,4 @@
#! /usr/bin/env bash #! /usr/bin/env bash
image=harbor-contest.4pd.io/zhanghao/diffusers:bi100-0.2 image=diffusers:v0.1
docker run -it -v /root/zhanghao:/workspace -v /mnt:/mnt --device=dev/iluvatar1:/dev/iluvatar0 $image bash device=cambricon_dev1
docker run -v `pwd`:/workspace -v /mnt/contest_ceph/zhanghao/models/stable-diffusion-v1-5:/workspace/stable-diffusion-v1-5 --device=/dev/$device:/dev/cambricon_dev0 --device=/dev/cambricon_ctl:/dev/cambricon_ctl $image python3 main.py --model "./stable-diffusion-v1-5" --json "dataset.json" --results "results.json" --outdir "output" --device cuda --dtype fp16

View File

@@ -1,3 +0,0 @@
#! /usr/bin/env bash
image=harbor-contest.4pd.io/zhanghao/diffusers:mrv100-0.2
docker run -it -v /root/zhanghao:/workspace -v /mnt:/mnt --device=dev/iluvatar0:/dev/iluvatar0 $image bash

13
test.py
View File

@@ -1,13 +0,0 @@
from diffusers import DiffusionPipeline
import torch
import time
model_path = "/mnt/contest_ceph/zhanghao/models/stable-diffusion-v1-5"
# model_path = "/mnt/contest_ceph/zhanghao/models/stable-diffusion-3.5-medium"
pipeline = DiffusionPipeline.from_pretrained(model_path, torch_dtype=torch.float16)
pipeline.to("cuda")
start = time.time()
image = pipeline("An image of a squirrel in Picasso style").images[0]
end = time.time()
print(f"elapsed: {end - start}")
image.save("squirrel_picasso.png")

View File

@@ -1,7 +0,0 @@
python3 main.py \
--model "/mnt/contest_ceph/zhanghao/models/stable-diffusion-v1-5" \
--json "dataset.json" \
--results "results.json" \
--outdir "output" \
--device cuda \
--dtype fp16