siliconflow / onediff

OneDiff: An out-of-the-box acceleration library for diffusion models.
https://github.com/siliconflow/onediff/wiki
Apache License 2.0
1.71k stars 105 forks source link

[Bug] Should SDXL work with nexfort backend in ComfyUI? #1114

Open asagi4 opened 2 months ago

asagi4 commented 2 months ago

Your current environment information

$ python -m onediff.utils.collect_env
Collecting environment information... PyTorch version: 2.4.1+cu124 Is debug build: False CUDA used to build PyTorch: 12.4 ROCM used to build PyTorch: N/A

OneFlow version: path: ['/home/sd/venvs/comfy/lib/python3.11/site-packages/oneflow'], version: 0.9.1.dev20240920+cu122, git_commit: d23c061, cmake_build_type: Release, rdma: True, mlir: True, enterprise: False Nexfort version: 0.1.dev271
OneDiff version: 1.2.1.dev23+g104a6d6c.d20240902 OneDiffX version: 1.2.1.dev23+g6463100f.d20240831

OS: Red Hat Enterprise Linux 9.4 (Plow) (x86_64)
GCC version: (GCC) 11.4.1 20231218 (Red Hat 11.4.1-3) Clang version: Could not collect
CMake version: version 3.26.5
Libc version: glibc-2.34

Python version: 3.11.9 (main, Apr 19 2024, 16:48:06) [GCC 11.2.0] (64-bit runtime) Python platform: Linux-5.14.0-427.35.1.el9_4.x86_64-x86_64-with-glibc2.34 Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3060 Nvidia driver version: 550.90.12 cuDNN version: Probably one of the following:
/usr/lib64/libcudnn.so.8.9.7
/usr/lib64/libcudnn.so.9.4.0
/usr/lib64/libcudnn_adv.so.9.4.0
/usr/lib64/libcudnn_adv_infer.so.8.9.7
/usr/lib64/libcudnn_adv_train.so.8.9.7 /usr/lib64/libcudnn_cnn.so.9.4.0
/usr/lib64/libcudnn_cnn_infer.so.8.9.7
/usr/lib64/libcudnn_cnn_train.so.8.9.7
/usr/lib64/libcudnn_engines_precompiled.so.9.4.0
/usr/lib64/libcudnn_engines_runtime_compiled.so.9.4.0
/usr/lib64/libcudnn_graph.so.9.4.0
/usr/lib64/libcudnn_heuristic.so.9.4.0
/usr/lib64/libcudnn_ops.so.9.4.0
/usr/lib64/libcudnn_ops_infer.so.8.9.7
/usr/lib64/libcudnn_ops_train.so.8.9.7
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
CPU:
Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit
Address sizes: 39 bits physical, 48 bits virtual
Byte Order: Little Endian CPU(s): 4
On-line CPU(s) list: 0-3
Vendor ID: GenuineIntel
Model name: Intel(R) Core(TM) i5-4670 CPU @ 3.40GHz
CPU family: 6
Model: 60 Thread(s) per core: 1 Core(s) per socket: 4 Socket(s): 1
Stepping: 3
CPU(s) scaling MHz: 99%
CPU max MHz: 3800.0000 CPU min MHz: 800.0000 BogoMIPS: 6784.14 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm cpuid_fault epb pti ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt dtherm ida arat pln pts md_clear flush_l1d
L1d cache: 128 KiB (4 instances) L1i cache: 128 KiB (4 instances) L2 cache: 1 MiB (4 instances) L3 cache: 6 MiB (1 instance) NUMA node(s): 1 NUMA node0 CPU(s): 0-3 Vulnerability Gather data sampling: Not affected Vulnerability Itlb multihit: KVM: Mitigation: VMX unsupported
Vulnerability L1tf: Mitigation; PTE Inversion
Vulnerability Mds: Mitigation; Clear CPU buffers; SMT disabled
Vulnerability Meltdown: Mitigation; PTI Vulnerability Mmio stale data: Unknown: No mitigations
Vulnerability Retbleed: Not affected Vulnerability Spec rstack overflow: Not affected Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; Retpolines, IBPB conditional, IBRS_FW, STIBP disabled, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds: Mitigation; Microcode Vulnerability Tsx async abort: Not affected

Versions of relevant libraries:
[pip3] diffusers==0.29.1
[pip3] numpy==2.1.1
[pip3] onnx==1.16.1
[pip3] torch==2.4.1+cu124
[pip3] torch_tensorrt==2.4.0+cu124
[pip3] torchaudio==2.4.1+cu124
[pip3] torchsde==0.2.6
[pip3] torchvision==0.19.1+cu124
[pip3] transformers==4.44.0
[pip3] triton==3.0.0
[conda] numpy 2.0.1 pypi_0 pypi

🐛 Describe the bug

I'm trying to test the nexfort compiler backend instead of oneflow for optimizing an SDXL model with ComfyUI, since with oneflow I sometimes get crashes when it runs out of memory using a controlnet (it kills the ComfyUI server completely rather than throwing an OOM exception).

However, it seems that when nexfort starts optimizing the model, it just causes the ComfyUI main python process to run at 100% CPU forever, seemingly not making any progress. I see it forks 4 subprocesses that look like they could be the compiler processes but they consistently show 0% CPU usage. I've tried letting it run for an hour or so, but it seems to make no progress.

Can nexfort be used with SDXL at all in ComfyUI, or is it known that it won't work?

In addition I have the following environment variables, but setting them one way or the other doesn't seem to affect anything.

export NEXFORT_FX_CUDAGRAPHS=1
export NEXFORT_FX_CONV_BENCHMARK=0
export NEXFORT_FX_MATMUL_ALLOW_TF32=0
export TORCHINDUCTOR_FX_GRAPH_CACHE=1
export NEXFORT_GRAPH_CACHE=1
export TORCHINDUCTOR_CACHE_DIR=~/.torchinductor_cache
export COMFYUI_ONEDIFF_SAVE_GRAPH_DIR=/home/sd/output/graphs
liho00 commented 2 weeks ago

same issue here, @asagi4 did you figure out?

asagi4 commented 2 weeks ago

@liho00 nope. I switched back to oneflow and just deal with the crashes.