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

How to using CPU for elmo? #16

Closed
ybdesire opened this issue Jul 15, 2020 · 2 comments
Closed

How to using CPU for elmo? #16

ybdesire opened this issue Jul 15, 2020 · 2 comments

Comments

@ybdesire
Copy link

ybdesire commented Jul 15, 2020

I run below cmd at my CPU environment as the readme said

python -m preprocess.get_elmo_vec data/conll2003/

but get errors below, since I do not have GPU

Traceback (most recent call last):
  File "/root/anaconda3/envs/pt_lstmcrf/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/root/anaconda3/envs/pt_lstmcrf/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/tmp/pytorch_lstmcrf/preprocess/get_elmo_vec.py", line 99, in <module>
    get_vector()
  File "/home/tmp/pytorch_lstmcrf/preprocess/get_elmo_vec.py", line 75, in get_vector
    elmo = load_elmo(cuda_device)
  File "/home/tmp/pytorch_lstmcrf/preprocess/get_elmo_vec.py", line 38, in load_elmo
    return ElmoEmbedder(cuda_device=cuda_device)
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

Would you share the steps to get elmo word embedding by CPU ?

@allanj
Copy link
Owner

allanj commented Jul 15, 2020

You can simply change cuda_device to -1 in https://github.com/allanj/pytorch_lstmcrf/blob/master/preprocess/get_elmo_vec.py#L74

By replace

cuda_device = 0

with

cuda_device = -1

Such that it will be using CPU.
Feel free to reopen the issue if you run into other problems.

@allanj allanj closed this as completed Jul 15, 2020
@ybdesire
Copy link
Author

Thanks @allanj for the help.

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