WindChimeRan / pytorch_multi_head_selection_re

BERT + reproduce "Joint entity recognition and relation extraction as a multi-head selection problem" for Chinese and English IE
138 stars 31 forks source link

CUDA error #4

Closed antgr closed 5 years ago

antgr commented 5 years ago

In google colab environment

!python main.py --mode train --exp_name conll_selection_re gives the following error

Traceback (most recent call last): File "main.py", line 146, in config.run(mode=args.mode) File "main.py", line 76, in run self._init_model() File "main.py", line 57, in _init_model self.model = MultiHeadSelection(self.hyper).cuda(self.gpu) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 265, in cuda return self._apply(lambda t: t.cuda(device)) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 193, in _apply module._apply(fn) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 199, in _apply param.data = fn(param.data) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 265, in return self._apply(lambda t: t.cuda(device)) RuntimeError: CUDA error: invalid device ordinal

WindChimeRan commented 5 years ago

You only have one GPU in colab. Thus, set device gpu=0.

Please see my config file:

https://github.com/WindChimeRan/pytorch_multi_head_selection_re/blob/master/experiments/conll_selection_re.json#L23

antgr commented 5 years ago

Thank you!