Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7900XTX Severely reduced SD single batch performance when moving from 5.6 to 5.7 #1298

Open
errnoh opened this issue Oct 17, 2023 · 0 comments

Comments

@errnoh
Copy link

errnoh commented Oct 17, 2023

🐛 Describe the bug

Moving from 2.2.0.dev20231017+rocm5.6 to 2.2.0.dev20231016+rocm5.7 introduced weird behavior. As this happens with just uninstalling previous torch versions and installing new one it seems to point torch being the source.

What I'm observing is that when using the above version Stable Diffusion inference slows down to crawl, calls that should take seconds take minutes. What's interesting is that this seems to happen only with batch size of one and increasing batch size to two or more doesn't have this issue and keeps working as fast as expected.

I'm not sure how to reproduce the issue in a simple way apart from a Stable Diffusion API call below, where doing call with batch_size 1 takes over two minutes and batch_size of 2 takes three seconds.

With 2.2.0.dev20231016+rocm5.7 this happens:

curl -X POST -H "Content-Type: application/json" http://127.0.0.1:7860/sdapi/v1/txt2img -d '{"width":512,"height":512,"batch_size":1,"seed":1234,"prompt":"a dog"}'
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 50/50 [02:34<00:00,  3.09s/it]
curl -X POST -H "Content-Type: application/json" http://127.0.0.1:7860/sdapi/v1/txt2img -d '{"width":512,"height":512,"batch_size":2,"seed":1234,"prompt":"a dog"}'
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 50/50 [00:03<00:00, 13.05it/s]

Reverting back to 5.6 with:

pip uninstall torch torchvision torchaudio
pip install --pre torch torchaudio torchvision  --index-url https://download.pytorch.org/whl/nightly/rocm5.6

resulting in 2.2.0.dev20231017+rocm5.6 goes back to the normal behavior:

curl -X POST -H "Content-Type: application/json" http://127.0.0.1:7860/sdapi/v1/txt2img -d '{"width":512,"height":512,"batch_size":1,"seed":1234,"prompt":"a dog"}'
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 50/50 [00:02<00:00, 22.96it/s]
curl -X POST -H "Content-Type: application/json" http://127.0.0.1:7860/sdapi/v1/txt2img -d '{"width":512,"height":512,"batch_size":2,"seed":1234,"prompt":"a dog"}'
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 50/50 [00:03<00:00, 13.58it/s]

Versions

PyTorch version: 2.2.0.dev20231016+rocm5.7
Is debug build: False
CUDA used to build PyTorch: N/A
ROCM used to build PyTorch: 5.7.31921-d1770ee1b

OS: Fedora Linux 36 (Container Image) (x86_64)
GCC version: (GCC) 12.2.1 20221121 (Red Hat 12.2.1-4)
Clang version: Could not collect
CMake version: version 3.27.5
Libc version: glibc-2.35

Python version: 3.10.11 (main, Apr 5 2023, 00:00:00) [GCC 12.2.1 20221121 (Red Hat 12.2.1-4)] (64-bit runtime)
Python platform: Linux-6.1.52-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: AMD Radeon Graphics
Nvidia driver version: Could not collect
cuDNN version: Could not collect
HIP runtime version: 5.7.31921
MIOpen runtime version: 2.20.0
Is XNNPACK available: True

CPU:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 48 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 24
On-line CPU(s) list: 0-23
Vendor ID: AuthenticAMD
Model name: AMD Ryzen 9 5900X 12-Core Processor
CPU family: 25
Model: 33
Thread(s) per core: 2
Core(s) per socket: 12
Socket(s): 1
Stepping: 0
Frequency boost: enabled
CPU(s) scaling MHz: 77%
CPU max MHz: 4950,1948
CPU min MHz: 2200,0000
BogoMIPS: 7385.79
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr rdpru wbnoinvd arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif v_spec_ctrl umip pku ospke vaes vpclmulqdq rdpid overflow_recov succor smca fsrm
Virtualization: AMD-V
L1d cache: 384 KiB (12 instances)
L1i cache: 384 KiB (12 instances)
L2 cache: 6 MiB (12 instances)
L3 cache: 64 MiB (2 instances)
NUMA node(s): 1
NUMA node0 CPU(s): 0-23
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit: Not affected
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Mmio stale data: Not affected
Vulnerability Retbleed: Not affected
Vulnerability Spec rstack overflow: Mitigation; safe RET, no microcode
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 always-on, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected

Versions of relevant libraries:
[pip3] numpy==1.23.5
[pip3] onnx==1.14.1
[pip3] onnxruntime==1.15.1
[pip3] open-clip-torch==2.20.0
[pip3] pytorch-lightning==1.9.4
[pip3] pytorch-triton-rocm==2.1.0+34f8189eae
[pip3] torch==2.2.0.dev20231016+rocm5.7
[pip3] torchaudio==2.2.0.dev20231016+rocm5.7
[pip3] torchdiffeq==0.2.3
[pip3] torchmetrics==1.1.2
[pip3] torchsde==0.2.5
[pip3] torchvision==0.17.0.dev20231016+rocm5.7
[conda] Could not collect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant