tensorflow / models

Models and examples built with TensorFlow
Other
77.04k stars 45.77k forks source link

Same code running optimized in Windows and heavy in Linux #10428

Closed dsjosh closed 2 years ago

dsjosh commented 2 years ago

[✔️ ] I am using the latest TensorFlow Model Garden release and TensorFlow 2 [ ✔️] I am reporting the issue to the correct repository [✔️ ] I checked to make sure that this issue has not already been filed

File URL

https://github.com/tensorflow/models/blob/master/research/audioset/yamnet/inference.py

Bug Description

I understand that usually codes run more efficiently in Linux than Windows, but in my case it is opposite. This, along with the fact that there is a 12x CPU Usage and 2x RAM Usage, leads me to believe that there might be an optimization issue.

The cross-platform code works on both Windows and Ubuntu.

In Windows: -2% CPU Usage -200MB RAM

In Ubuntu: -25% CPU Usage -465MB RAM

Variables I have kept constant: -Same Hardware (Dual boot from same SSD with 2 partitions on Intel Core i5 4460) -Both platforms freshly installed (not bloated OS) -Both platforms using CPU (not GPU) -Same code -Same Python version -Same TF version

Steps to reproduce

Just running the "inference.py" from Yamnet in a forever loop to predict realtime audio captured by "sounddevice" libary

Expected behavior

From my understanding, the code running on Linux should be the same or more efficient than Windows.

Additional context

Logs from your environment capture script: old-tf_env.txt tf_env.txt

If I'm missing any logs, please let me know and I'll submit them.

System information

plakal commented 2 years ago

Please note that the YAMNet inference demo is a toy and is only meant to show how to pass audio data from an audio file into the model and read out the predictions. If you wanted to do real-time inference on an audio stream, you would definitely not repeatedly run inference.py as it's written, you would write your own custom audio-handling loop.

The performance differences you are seeing between Windows and Linux are out of scope for us, and are probably due to some differences in TensorFlow, Python, NumPy, resampy, and your specific setup. It might be better to ask this on some more general forum (Stack Overflow, etc).

google-ml-butler[bot] commented 2 years ago

Are you satisfied with the resolution of your issue? Yes No

dsjosh commented 2 years ago

Thank you @plakal and @kumariko . That makes sense.