【深度学习】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

相关推荐
就是一顿骚操作1 分钟前
VGG:用小卷积块把 CNN 做深的经典解读
人工智能·深度学习·神经网络·cnn·论文解读
奈斯先生Vector6 分钟前
AI 视频不是会动的图片:用 Shot Contract、时间码与音画质检构建可交付流水线
人工智能·重构·架构·prompt·aigc·音视频
男孩李15 分钟前
浅谈JiuwenSwarm安装
人工智能·语言模型·自然语言处理
anscos16 分钟前
案例分享| Latitude AI × Parasoft:搭建 L2-L3 自动驾驶量产验证与功能安全完整链路
人工智能·安全·自动驾驶
深念Y16 分钟前
基于 NapCat 与本地 RAG 的群聊 AI 机器人方案(ARM64 部署)
人工智能·ai·机器人·node.js·自动化·情感陪伴·bot
工业HMI实战笔记16 分钟前
解放双手,声控未来:抗噪语音交互如何革新嘈杂车间的HMI操作体验
人工智能·学习·自动化·制造
ai产品老杨17 分钟前
AI视频分析并发优化参数配置说明
人工智能·音视频
怪奇云呼军21 分钟前
G.711、Opus 和重采样会拖慢识别吗?闪电智能VoiceAgent 的音频入口怎么选
java·人工智能·python·算法·云计算·音视频
星空彼岸00724 分钟前
AI大模型的能力边界
人工智能
chen_zn9528 分钟前
《VLA 系列》π0 | Flow Matching 动作专家 | 跨本体机器人策略 | 论文与源码解析
人工智能·具身智能·vla