KavrakiLab / KavrakiLab/Spec2Mol

"--device cpu" does not work when running decode_embeddings.py

Open
#4 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
30
Forks
15
PR merge metrics
No merged PRs in 30d

Description

Hello,

I am running on my laptop, a device that does not have a GPU.

When I ran the following command:
"python -m scripts.decode_embeddings --output_file decoded_output.csv --predicted_embeddings sample.pt --model translation --device cpu --model_load models/model.pt --vocab_load models/vocab.nb --config_load models/config.nb --n_batch 65 --num_variants 3"

I got this error:
"ArgumentParser(prog='decode_embeddings.py', usage=None, description=None, formatter_class=, conflict_handler='error', add_help=True)
Namespace(config_load='models/config.nb', device='cpu', model='translation', model_load='models/model.pt', n_batch=65, num_variants=3, output_file='decoded_output.csv', predicted_embeddings='sample.pt', vocab_load='models/vocab.nb')
{'#': 0, '%': 1, '(': 2, ')': 3, '+': 4, '-': 5, '0': 6, '1': 7, '2': 8, '3': 9, '4': 10, '5': 11, '6': 12, '7': 13, '8': 14, '9': 15, '=': 16, 'B': 17, 'Br': 18, 'C': 19, 'Cl': 20, 'F': 21, 'H': 22, 'I': 23, 'N': 24, 'O': 25, 'P': 26, 'S': 27, '[': 28, ']': 29, 'c': 30, 'n': 31, 'o': 32, 'p': 33, 's': 34, '': 35, '': 36, '': 37, '': 38}
0%| | 0/1 [00:00
main(config.model, config)
File "C:\Users\pearsor5\Documents\Scripts\Spec2mol_Test\Spec2Mol\decoder\scripts\decode_embeddings.py", line 166, in main
config.num_variants,
File "C:\Users\pearsor5\Documents\Scripts\Spec2mol_Test\Spec2Mol\decoder\scripts\decode_embeddings.py", line 45, in decode
mu_predicted = mu_predicted.cuda()
File "C:\Users\pearsor5\AppData\Local\miniconda3\envs\spec2mol\lib\site-packages\torch\cuda\__init__.py", line 186, in _lazy_init
_check_driver()
File "C:\Users\pearsor5\AppData\Local\miniconda3\envs\spec2mol\lib\site-packages\torch\cuda\__init__.py", line 68, in _check_driver
http://www.nvidia.com/Download/index.aspx""")
AssertionError:
Found no NVIDIA driver on your system. Please check that you
have an NVIDIA GPU and installed a driver from
http://www.nvidia.com/Download/index.aspx"

To fix my issue, I edited line 45 in the decode_embeddings.py script.

Line 45 was changed from:
" mu_predicted = mu_predicted.cuda()" to " mu_predicted = mu_predicted.to(config.device)".

After some minor changes to the code I was able to get the example working and the output was the following:
![image](https://github.com/KavrakiLab/Spec2Mol/assets/81730040/70a52f4f-ce30-47b2-bede-7eedf61f1827)

Thanks for making the code available!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.