Alibaba-NLP / ACE

[ACL-IJCNLP 2021] Automated Concatenation of Embeddings for Structured Prediction
Other
298 stars 44 forks source link

Is GPU required? #40

Closed junwei-h closed 2 years ago

junwei-h commented 2 years ago

Hello, I run python train.py --config config/conll_03_english.yaml --test on Windows 10, python 3.7, no GPU and got AssertionError: Torch not compiled with CUDA enabled at https://github.com/Alibaba-NLP/ACE/blob/main/flair/trainers/distillation_trainer.py#L1160

Is there a work-around for no GPU env? Thank you.

Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Users\ebb\.conda\envs\ace_py37\lib\site-packages\torch\nn\modules\module.py", line 305, in cuda return self._apply(lambda t: t.cuda(device)) File "C:\Users\ebb\.conda\envs\ace_py37\lib\site-packages\torch\nn\modules\module.py", line 202, in _apply module._apply(fn) File "C:\Users\ebb\.conda\envs\ace_py37\lib\site-packages\torch\nn\modules\module.py", line 202, in _apply module._apply(fn) File "C:\Users\ebb\.conda\envs\ace_py37\lib\site-packages\torch\nn\modules\module.py", line 224, in _apply param_applied = fn(param) File "C:\Users\ebb\.conda\envs\ace_py37\lib\site-packages\torch\nn\modules\module.py", line 305, in <lambda> return self._apply(lambda t: t.cuda(device)) File "C:\Users\ebb\.conda\envs\ace_py37\lib\site-packages\torch\cuda\__init__.py", line 192, in _lazy_init _check_driver() File "C:\Users\ebb\.conda\envs\ace_py37\lib\site-packages\torch\cuda\__init__.py", line 95, in _check_driver raise AssertionError("Torch not compiled with CUDA enabled") AssertionError: Torch not compiled with CUDA enabled

wangxinyu0922 commented 2 years ago

Yes, GPU is required in this repo. Training the model without GPU will be very slow.

junwei-h commented 2 years ago

Thank you for your quick reply. I have no plan for fine-tuning, only testing and prediction. For this use case, do I still need a GPU?

wangxinyu0922 commented 2 years ago

Thank you for your quick reply. I have no plan for fine-tuning, only testing and prediction. For this use case, do I still need a GPU?

I have not tested whether the code can run without GPU. If you still want to use the model, please modify all .cuda() commands into .to(flair.device) and change embedding.ee.cuda_device into flair.device for your referenced line.

junwei-h commented 2 years ago

Thank you very much. That trick works. I was able to get the final test results identical to the one you showed.

For reference, I run on Python 3.7, Windows 10, CPU only.

python train.py --config config/conll_03_english.yaml --test

Result: 2022-07-22 15:51:08,361 0.9309 0.9423 0.9366 2022-07-22 15:51:08,361 MICRO_AVG: acc 0.8807 - f1-score 0.9366 MACRO_AVG: acc 0.8635 - f1-score 0.9247500000000001 LOC tp: 1580 - fp: 90 - fn: 88 - tn: 1580 - precision: 0.9461 - recall: 0.9472 - accuracy: 0.8987 - f1-score: 0.9466 MISC tp: 606 - fp: 115 - fn: 96 - tn: 606 - precision: 0.8405 - recall: 0.8632 - accuracy: 0.7417 - f1-score: 0.8517 ORG tp: 1561 - fp: 159 - fn: 100 - tn: 1561 - precision: 0.9076 - recall: 0.9398 - accuracy: 0.8577 - f1-score: 0.9234 PER tp: 1575 - fp: 31 - fn: 42 - tn: 1575 - precision: 0.9807 - recall: 0.9740 - accuracy: 0.9557 - f1-score: 0.9773