Sign In

Note on using comfyUI / sd-scripts with Intel Arc B580 on Ubuntu 24.04.2

0

May 12, 2025

(Updated: 5 months ago)

generation guide
Note on using comfyUI / sd-scripts with Intel Arc B580 on Ubuntu 24.04.2

英語は機械訳です。以下私の経験に基づく個人的な備忘録なので間違いが含まれている可能性が有ります。

Sorry, the following text written in English is a machine translation. The following is based on my experience and may contain errors.

 

# PyTorch for Intel Arc installation guide links

PyTorch official

https://docs.pytorch.org/docs/stable/notes/get_start_xpu.html

Intel Extension for PyTorch(IPEX)

https://intel.github.io/intel-extension-for-pytorch/

# My PC Environment

OS: Ubuntu 24.04.2
CPU: AMD RYZEN 7 5700X
MEM: DDR4 3200MHz 64GB (32GB x 2)
M/B: ASUS TUF GAMING B550M-PLUS
GPU: SPARKLE TITAN B580 12GB

# ComfyUI (python=3.12)

Pytorch公式版(nightly)のtorch=2.8.0+xpu推奨

動画生成でモデルをメインメモリにオフロードする際、IPEX版はメモリ消費量が非常に多くRAM64GBだとクラッシュする。Pytorch公式版だとWAN2.1でunet,clip,vaeにbf16/fp16モデルを使っても50GB程度に収まる

Official Pytorch(nightly) torch=2.8.0+xpu is recommended

When offloading models to main memory for video generation, the IPEX version consumes so much memory that it crashes with 64GB of RAM, while the official version of Pytorch uses only 50GB with WAN2.1, even when using bf16/fp16 models for unet, clip, and vae.

# sd-scripts (python=3.10)

IPEX推奨(2.7.10, torch=2.7.0) Pytorch公式版だとLyCORISが動作したのはtorch=2.5.1+xpuだが現在入手できず

IPEX 2.7.10+xpu is recommended

・学習途中でNaNになる可能性が上がるオプション

・Options that prone to NaN during the learning process

--max_token_length=150
--max_token_length=225

・Tested sample train script

time accelerate launch --num_cpu_threads_per_process=1 sdxl_train_network.py \
--network_module="lycoris.kohya" --max_data_loader_n_workers=8 \
--mixed_precision=bf16 --save_precision=bf16 --save_model_as=safetensors \
--seed=1234 --caption_extention=".txt" \
--pretrained_model_name_or_path='models/Stable-diffusion/SDXL/Illustrious-XL-v0.1.safetensors' \
--resolution=1024 --max_bucket_reso=1536 --min_bucket_reso=512 --bucket_reso_steps=64 \
--train_data_dir=train --output_dir=output --logging_dir=log \
--max_train_steps=1999 --train_batch_size=2 --gradient_accumulation_steps=1 \
--save_every_n_steps=500 \
--learning_rate=1e-4 --text_encoder_lr=5e-5 \
--network_dim=8 --network_alpha=0.2 \
--network_args conv_dim=8 algo=loha dora_wd=True \
--optimizer_type="came_pytorch.CAME" --lr_scheduler=cosine_with_restarts --lr_scheduler_num_cycles=4 \
--optimizer_args "weight_decay=1e-2" "betas=(0.9, 0.999, 0.9999)" "eps=(1e-30, 1e-16)" \
--keep_tokens_separator='|||' --shuffle_caption \
--sdpa --gradient_checkpointing \
--noise_offset="0.04" \
--no_half_vae --enable_bucket --cache_latents \
--output_name=page_tear_il_xpu_doha
 
# result: 1999/1999 [6:29:55<00:00, 11.70s/it, avr_loss=0.101] 

# Code change

custom_nodeなど、そのままでは動かないものでもtorch.cudaをtorch.xpu、*("cuda")を*("xpu")などに書き換えるだけで動く場合が多い

・大雑把に書き換えるコマンド@Linux

・Roughly rewrite command in linux

sed -i 's/torch.cuda/torch.xpu/g' *.py
sed -i -e "s/\'cuda\'/\'xpu\'/g" -e 's/\"cuda\"/\"xpu\"/g' -e 's/cuda0/xpu0/' *.py

 

・torch.xpuに対応する命令がない or B580が対応していない命令の例

・Examples of instructions not supported by torch.xpu or not supported by B580,

torch.cuda.memory_stats()
torch.cuda.ipc_collect()

この場合は対応できる形に書き換えたりコメントアウトする

to rewrite or comment out the relevant code.

0