はじめに
huggingface.coDDUFファイルとは(公式ページから引用)
DDUF (Diffusion Unified Format) is a file format designed to make storing, distributing, and using diffusion models much easier. Built on the ZIP file format, DDUF offers a standardized, efficient, and flexible way to package all parts of a diffusion model into a single, easy-to-manage file.
DeepLで翻訳
DDUF (Diffusion Unified Format)は、拡散モデルの保存、配布、使用をより簡単にするためにデザインされたファイルフォーマットです。ZIPファイルフォーマットをベースに構築されたDDUFは、拡散モデルのすべてのパーツを、標準化された効率的で柔軟な方法で、管理しやすい1つのファイルにパッケージ化します。
GGUFというのもあります。ややこしい。
touch-sp.hatenablog.com
使用したPC
OS Windows 11 プロセッサ Intel(R) Core(TM) i7-12700H 実装 RAM 32.0 GB GPU RTX 3080 Laptop (VRAM 16GB)
CUDA 11.8 Python 3.12
Python環境構築
pip install torch==2.5.1+cu118 --index-url https://download.pytorch.org/whl/cu118 pip install git+https://github.com/huggingface/diffusers pip install accelerate transformers protobuf sentencepiece bitsandbytes
accelerate==1.2.1 bitsandbytes==0.45.0 diffusers @ git+https://github.com/huggingface/diffusers@3d70777379eca6ea36527e978602f9adc40ae5fc protobuf==5.29.3 sentencepiece==0.2.0 torch==2.5.1+cu118 transformers==4.48.0
Pythonスクリプト
from diffusers import StableDiffusion3Pipeline import torch from decorator import gpu_monitor, time_monitor @gpu_monitor(interval=0.5) @time_monitor def main(): pipe = StableDiffusion3Pipeline.from_pretrained( "DDUF/stable-diffusion-3.5-large-DDUF", dduf_file="stable-diffusion-3.5-large-Q4-bnb.dduf", torch_dtype=torch.bfloat16 ).to("cuda") image = pipe( "A cat holding a sign that says hello world", generator=torch.manual_seed(0) ).images[0] image.save("cat.jpg") print(f"torch.cuda.max_memory_allocated: {torch.cuda.max_memory_allocated()/ 1024**3:.2f} GB") if __name__ == "__main__": main()
結果
torch.cuda.max_memory_allocated: 14.49 GB time: 105.10 sec GPU 0 - Used memory: 15.93/16.00 GB

その他
ベンチマークはこちらで記述したスクリプトで行いました。touch-sp.hatenablog.com