snakers4 / silero-models

Silero Models: pre-trained speech-to-text, text-to-speech and text-enhancement models made embarrassingly simple
Other
4.86k stars 303 forks source link

Bug report - very slow warmup on first 2 lines of synthesis with pytorch-cuda #223

Closed S-trace closed 1 year ago

S-trace commented 1 year ago

🐛 Bug

The first two lines are synthesized very slowly (up to 3 minutes to process 26 characters). if pytorch-cuda is installed. After the second line I got the following message:

/usr/lib/python3.10/site-packages/torch/nn/modules/module.py:1501: UserWarning: operator() profile_node %934 : int[] = prim::profile_ivalue(%932)
 does not have profile information (Triggered internally at /build/python-pytorch/src/pytorch-2.0.0-cuda/third_party/nvfuser/csrc/graph_fuser.cpp:104.)
  return forward_call(*args, **kwargs)

Subsequent lines are synthesized normally (1 second for 640 characters block). The Python interpreter takes 100% CPU load (consumes one CPU core) during this delay. The delay happens both with 'cpu' and 'cuda' PyTorch devices.

To Reproduce

  1. Load the model using the following code:
    torch_dev: torch.device = torch.device("cuda", 0)
    torch.set_num_threads(6)
    tts_model, tts_sample_text = torch.hub.load(repo_or_dir='snakers4/silero-models',
                                                model='silero_tts',
                                                language=language,
                                                speaker=model_id)
    tts_model.to(torch_dev)
  2. Try to spell several text lines using the following code in a loop iterating text lines array:
            audio = tts_model.apply_tts(text=line,
                                        speaker=speaker,
                                        sample_rate=sample_rate,
                                        put_accent=put_accent,
                                        put_yo=put_yo)

The complete script: https://github.com/S-trace/silero_tts_standalone/blob/master/tts.py

Expected behavior

First lines should be synthesized without such a huge delay (2-3 seconds maybe, but not 3 minutes).

Environment

Collecting environment information... PyTorch version: 2.0.0 Is debug build: False CUDA used to build PyTorch: 12.1 ROCM used to build PyTorch: N/A

OS: Manjaro Linux (x86_64) GCC version: (GCC) 12.2.1 20230201 Clang version: 15.0.7 CMake version: version 3.26.3 Libc version: glibc-2.37

Python version: 3.10.10 (main, Mar 5 2023, 22:26:53) [GCC 12.2.1 20230201] (64-bit runtime) Python platform: Linux-6.2.10-1-MANJARO-x86_64-with-glibc2.37 Is CUDA available: True CUDA runtime version: 12.1.66 CUDA_MODULE_LOADING set to: LAZY GPU models and configuration: GPU 0: NVIDIA GeForce GTX 1050 Ti Nvidia driver version: 530.41.03 cuDNN version: Probably one of the following: /usr/lib/libcudnn.so.8.8.0 /usr/lib/libcudnn_adv_infer.so.8.8.0 /usr/lib/libcudnn_adv_train.so.8.8.0 /usr/lib/libcudnn_cnn_infer.so.8.8.0 /usr/lib/libcudnn_cnn_train.so.8.8.0 /usr/lib/libcudnn_ops_infer.so.8.8.0 /usr/lib/libcudnn_ops_train.so.8.8.0 HIP runtime version: N/A MIOpen runtime version: N/A Is XNNPACK available: True

CPU: Архитектура: x86_64 CPU op-mode(s): 32-bit, 64-bit Address sizes: 39 bits physical, 48 bits virtual Порядок байт: Little Endian CPU(s): 12 On-line CPU(s) list: 0-11 ID прроизводителя: GenuineIntel Имя модели: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz Семейство ЦПУ: 6 Модель: 158 Thread(s) per core: 2 Ядер на сокет: 6 Сокетов: 1 Степпинг: 10 CPU(s) scaling MHz: 95% CPU max MHz: 4100,0000 CPU min MHz: 800,0000 BogoMIPS: 4401,32 Флаги: 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 art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx 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 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d arch_capabilities Виртуализация: VT-x L1d cache: 192 KiB (6 instances) L1i cache: 192 KiB (6 instances) L2 cache: 1,5 MiB (6 instances) L3 cache: 9 MiB (1 instance) NUMA node(s): 1 NUMA node0 CPU(s): 0-11 Vulnerability Itlb multihit: KVM: Mitigation: VMX disabled Vulnerability L1tf: Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable Vulnerability Mds: Mitigation; Clear CPU buffers; SMT vulnerable Vulnerability Meltdown: Mitigation; PTI Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable Vulnerability Retbleed: Mitigation; IBRS 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; IBRS, IBPB conditional, STIBP conditional, RSB filling, PBRSB-eIBRS Not affected Vulnerability Srbds: Mitigation; Microcode Vulnerability Tsx async abort: Not affected

Versions of relevant libraries: [pip3] flake8==6.0.0 [pip3] numpy==1.24.2 [pip3] torch==2.0.0 [conda] Could not collect

Additional context

The delay is much less with python-pytorch (only 14 seconds to process same lines).

snakers4 commented 1 year ago

The first two lines are synthesized very slowly (up to 3 minutes to process 26 characters). if pytorch-cuda is installed. Subsequent lines are synthesized normally (1 second for 640 characters block). The Python interpreter takes 100% CPU load (consumes one CPU core) during this delay.

Does this help https://github.com/snakers4/silero-models/issues/183?

S-trace commented 1 year ago

Does this help #183?

I have added torch._C._jit_set_profiling_mode(False) # Fixes initial delay to my script, and it fixed the initial delay. Thank you!