snakers4 / silero-vad

Silero VAD: pre-trained enterprise-grade Voice Activity Detector
MIT License
3.38k stars 353 forks source link

Purpose of torch.set_num_threads(1) #440

Closed vikcost closed 3 months ago

vikcost commented 3 months ago

Hi, thanks for releasing a decent VAD model!

While looking through examples, I saw multiple times usage of: torch.set_num_threads(1) I haven't observed any performance difference with and without num_threads = 1 both for jit and onnx models.

Curious, what's the intended purpose of that statement?

snakers4 commented 3 months ago

While looking through examples, I saw multiple times usage of: torch.set_num_threads(1)

This is to indicate that the VAD needs only one CPU thread and does not consume much compute.

I haven't observed any performance difference with and without num_threads = 1 both for jit and onnx models.

This is correct. There should be very little, if any, difference. But when you do not set it, PyTorch eats all CPU threads by default. Also note that ONNX has a different way of setting its number of threads.