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

hebo take up too much cpus #10

Closed
Shaofei-Li opened this issue Mar 7, 2022 · 3 comments
Closed

hebo take up too much cpus #10

Shaofei-Li opened this issue Mar 7, 2022 · 3 comments

Comments

@Shaofei-Li
Copy link

The main process of HEBO take up 1600% cpus, which makes other parts of the program run very slowly. Is there any way to reduce the cpu usage of hebo? Thanks!

@Alaya-in-Matrix
Copy link
Collaborator

I think it's because numpy and pytorch used multi-threading for their computation, CPU usage should be limited if you disable numpy/torch multi-threading.

https://pytorch.org/docs/stable/generated/torch.set_num_threads.html

https://stackoverflow.com/questions/30791550/limit-number-of-threads-in-numpy

@Alaya-in-Matrix
Copy link
Collaborator

I just wrote a demo, adding the import os; os.environ..... statments reduces CPU usage from 800% to 100% on my own machine.

import os
os.environ['OMP_NUM_THREADS'] = '1'
os.environ['MKL_NUM_THREADS'] = '1'

from tqdm import trange
from hebo.optimizers.hebo import HEBO
from hebo.benchmarks.synthetic_benchmarks import RosenbrockDummy

if __name__ == '__main__':
    prob = RosenbrockDummy(10)
    opt  = HEBO(prob.space)
    tbar = trange(100)
    for i in tbar:
        rec = opt.suggest()
        y   = prob(rec)
        opt.observe(rec, y)
        tbar.set_description(f'Iter {i}, y = {y.min():.2f}, best_y = {opt.y.min():.2f}')

@Alaya-in-Matrix
Copy link
Collaborator

To me, numpy multi-threading does not seem to offer observable speed-up, so I actually just set the two environment variables to 1 in my .bashrc

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

2 participants