juanmc2005 / diart

A python package to build AI-powered real-time audio applications
https://diart.readthedocs.io
MIT License
903 stars 76 forks source link

High CPU usage #222

Closed arielrado closed 7 months ago

arielrado commented 7 months ago

I'm running the pipeline in a docker container from nvcr.io/nvida/pytorch:22.08 cuda version 11.7 with all gpus enabled, using the diart.serve console command. cpu utilization reaches 1000% according to htop, and sometimes 18000%. the gpu usage is relatively low at 515 MiB the cpu is Intel(R) Xeon(R) Silver 4216 CPU @ 2.10GHz and the gpu is nvidia RTX A6000 is this the expected amount of cpu usage, and if so what can be done to reduce it? the pipeline is supposed to run parallel to many other services and any cpu savings will go a long way.

SheenChi commented 7 months ago

Maybe you can set os.environ["OMP_NUM_THREADS"] = "1" in you code. when I run my test env use onnxruntime I had meet the high cpu usage problem, and solved it by set os.environ["OMP_NUM_THREADS"] = "1"

juanmc2005 commented 7 months ago

@arielrado are you using a pytorch or ONNX model? I have seen low GPU usage and high CPU usage in some cases with ONNX, but not with pytorch

arielrado commented 7 months ago

os.environ["OMP_NUM_THREADS"] = "1" seems to have solved it, thanks @SheenChi !