【深度学习】PixArt-Sigma 实战【3】速度测试

css 复制代码
import time

import torch
from diffusers import Transformer2DModel, PixArtSigmaPipeline
from diffusers import ConsistencyDecoderVAE

device = torch.device("cuda:1" if torch.cuda.is_available() else "cpu")
weight_dtype = torch.float16

pipe = PixArtSigmaPipeline.from_pretrained(
    "./PixArt-Sigma-XL-2-1024-MS",
    torch_dtype=weight_dtype,
    use_safetensors=True,
)
pipe.to(device)

# transformer = Transformer2DModel.from_pretrained(
#     # "PixArt-alpha/PixArt-Sigma-XL-2-1024-MS",
#     # "/ssd/xiedong/PixArt/PixArt-Sigma-XL-2-2K-MS",
#     "/ssd/xiedong/PixArt/PixArt-Sigma-XL-2-2K-MS",
#     subfolder='transformer',
#     torch_dtype=weight_dtype,
# )
# pipe = PixArtSigmaPipeline.from_pretrained(
#     # "PixArt-alpha/pixart_sigma_sdxlvae_T5_diffusers",
#     "/ssd/xiedong/PixArt/PixArt-sigma/output/pixart_sigma_sdxlvae_T5_diffusers",
#     transformer=transformer,
#     torch_dtype=weight_dtype,
#     use_safetensors=True,
# )
# pipe.vae = ConsistencyDecoderVAE.from_pretrained("/ssd/xiedong/PixArt/consistency-decoder", torch_dtype=torch.float16)
# pipe.to(device)

# Enable memory optimizations.
# pipe.enable_model_cpu_offload()

time1 = time.time()
prompt = "A small cactus with a happy face in the Sahara desert."
image = pipe(prompt).images[0]
time2 = time.time()
print(f"time use:{time2 - time1}")
image.save("./catcus.png")

time1 = time.time()
prompt = "A small cactus with a happy face in the Sahara desert."
image = pipe(prompt).images[0]
time2 = time.time()
print(f"time use:{time2 - time1}")
image.save("./catcus.png")

A100速度 20轮4.4秒。

Loading pipeline components...: 0%| | 0/5 00:00\You are using the default legacy behaviour of the <class 'transformers.models.t5.tokenization_t5.T5Tokenizer'>. This is expected, and simply means that the legacy (previous) behavior will be used so nothing changes for you. If you want to use the new behaviour, set legacy=False. This should only be set if you understand what it means, and thouroughly read the reason why this was added as explained in https://github.com/huggingface/transformers/pull/24565

Loading pipeline components...: 60%|██████ | 3/5 00:01\<00:01, 1.65it/s

Loading checkpoint shards: 0%| | 0/2 00:00\

Loading checkpoint shards: 50%|█████ | 1/2 00:01\<00:01, 1.83s/it

Loading checkpoint shards: 100%|██████████| 2/2 00:03\<00:00, 1.70s/it

Loading pipeline components...: 100%|██████████| 5/5 00:11\<00:00, 2.29s/it

100%|██████████| 20/20 00:05\<00:00, 3.89it/s

time use:6.027105093002319

100%|██████████| 20/20 00:04\<00:00, 4.94it/s

time use:4.406545162200928

相关推荐
冬奇Lab1 分钟前
AI 评测系列(03):LLM-as-Judge——让 LLM 评价 LLM 的正确姿势
人工智能·llm
Miao1213112 分钟前
某海外住宿平台如何在大规模场景下实现指标一致性:Minerva 指标平台实践
大数据·数据库·人工智能
冬奇Lab15 分钟前
每日一个开源项目(第164篇):毕昇(BISHENG)- 面向企业的开源 LLM DevOps 平台
人工智能·开源·agent
声讯电子1 小时前
录音笔AI降噪方案:从录得到到听得清的听觉革命
人工智能·语音识别
小小测试开发1 小时前
Playwright vs Selenium vs Cypress:从浏览器协议到 API 设计的全面对比与实测
人工智能·selenium·测试工具
Ai_easygo1 小时前
AI Agent开发入门——从ReAct到Tool Calling,拆解Agent的底层运行逻辑
前端·人工智能·react.js
IT_陈寒2 小时前
Redis的持久化配置把我坑惨了:你以为数据安全了?
前端·人工智能·后端
miaowu3572 小时前
AI智能体推动数字化转型:从流程自动化到决策辅助的完整路线图
大数据·人工智能·自动化
阿里云大数据AI技术2 小时前
阿里云 Elasticsearch 日志采集与加工服务:让日志链路少一串组件,多一份稳定
人工智能·elasticsearch
ksueh2 小时前
AI写小说长篇创作中的上下文局限与外部记忆系统实践
人工智能