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

Running in a Jupyter notebook works nicely. Running as a .py causes my computer to freeze due to insane cpu usage. #12

Open
willfinnigan opened this issue Nov 22, 2023 · 3 comments

Comments

@willfinnigan
Copy link

willfinnigan commented Nov 22, 2023

Running MolScribe in a Jupyter notebook works nicely for me. Running the same code as a .py causes my computer to freeze due to insane cpu usage.

Running this piece of code on M1 Mac

model = MolScribe(f'{folder}/data/swin_base_char_aux_1m.pth', device=torch.device('cpu'))

def mol_scribe_osr(filepath):
    output = model.predict_image_file(filepath, return_atoms_bonds=True, return_confidence=True)
    return output['smiles']
@thomas0809
Copy link
Owner

Hi,

Running a Python script should have similar performance to running a Jupyter notebook locally.

To limit CPU usage, please see https://discuss.pytorch.org/t/how-to-limit-the-number-of-cpus-used-by-pytorch/67254/2

@willfinnigan
Copy link
Author

Hi Thomas,

Thanks for the quick reply.

I agree, it seems really odd that I see this difference.

I tried running torch.set_num_threads(2) directly before the function call and in a few other places but with no luck. Looking in the activity monitor it seems 16 python processes are being launched (I have 10 cores - but 2 are slower). Running the code in a Jupiter notebook only launches a single process.

@tobbber
Copy link

tobbber commented Mar 6, 2024

@willfinnigan This might be related to #14, at least molscribe.chemistry.convert_graph_to_smiles spawns 16 processes as well

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