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

CPU time #82

Open
cyber42 opened this issue Jan 19, 2024 · 3 comments
Open

CPU time #82

cyber42 opened this issue Jan 19, 2024 · 3 comments

Comments

@cyber42
Copy link

cyber42 commented Jan 19, 2024

Hi,

I'm using timeout_decorator for machine learning workloads, ensuring that parameter optimizations terminate below pre-defined timeout. This helps in my process, but my workflow became sensitive to any other workload happening on the same host.

I wonder if terminating the function by CPU time is technically possible with the approach followed by timeout_decorator. This would ensure that the optmization step is independent of other processes using the host.

Would this make sense, I could fork / create a new branch or send a pull request with proposed changes.

Let me know if this makes sense, and if you'd be interested in intergrating this in the existing codebase.

Thanks, Mark

@bitranox
Copy link

bitranox commented Jan 19, 2024

Dear Mark,
I think thats a good idea.
In Python, you can measure CPU time using the time module. The time.process_time() function returns the current process time in seconds, which can be used to measure CPU time.
I guess my own timeout decorator can be easily adopted to archive that, since there is already a polling mechanism in there.
Check : https://github.com/bitranox/wrapt_timeout_decorator
I would simply add a parameter use_process_time which defauls to False to use wallclock time.
if that parameter is set to True we use process_time

I created a new issue on my repo : bitranox/wrapt_timeout_decorator#49

yours sincerely
Bitranox

@causalitygroup
Copy link

causalitygroup commented Jan 19, 2024

Sounds good, thanks! We're double checking the idea with my colleagues and get back to you.

Mark

@bitranox
Copy link

bitranox commented Jan 19, 2024

Dear Mark,
also check out the meaning of our hard_timeout parameter, for more accurate timing, since that considers also the time needed to fork (or to simulate a fork on windows) - so You get get a more accurate timing.
(the default is hard_timeout = False, so the timeout starts to be calculated when the spawned process is really starting.
Of course the timeout method multiprocessing is needed to archive that.
If You spawn many processes, the spawning itself might take a considerable time, especially on windows - that will be considered here, so Your learning processes will all get the same process_time.

yours sincerely
Bitranox

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

3 participants