yangheng95 / PyABSA

Sentiment Analysis, Text Classification, Text Augmentation, Text Adversarial defense, etc.;
https://pyabsa.readthedocs.io
MIT License
937 stars 159 forks source link

Torch not compiled with CUDA enabled #29

Closed zhihao-chen closed 3 years ago

zhihao-chen commented 3 years ago

I have run the "https://github.com/yangheng95/PyABSA/blob/release/examples/aspect_term_extraction/extract_aspects_chinese.py" on CPU device, and set "auto_device=False", but error message received that "Torch not compiled with CUDA enabled"。I have checked the class of "AspectExtractor" and the model class of "LCF_ATEPC", but no mistake were found。

yangheng95 commented 3 years ago

Can you show the stack trace? I didnt notice the occasion that using torch compiled without cuda, I will check and update soon.

zhihao-chen commented 3 years ago

Of course! Traceback (most recent call last): File "/Users/czh/bailian_workplace/mashi/tests/pyabsa_test.py", line 46, in <module> pred_sentiment=True, # Predict the sentiment of extracted aspect terms File "/Users/czh/anaconda3/envs/mashi/lib/python3.7/site-packages/pyabsa-0.7.1.0-py3.7.egg/pyabsa/module/atepc/inferring/aspect_extractor.py", line 145, in extract_aspect File "/Users/czh/anaconda3/envs/mashi/lib/python3.7/site-packages/pyabsa-0.7.1.0-py3.7.egg/pyabsa/module/atepc/inferring/aspect_extractor.py", line 195, in _extract File "/Users/czh/anaconda3/envs/mashi/lib/python3.7/site-packages/torch/nn/modules/module.py", line 889, in _call_impl result = self.forward(*input, **kwargs) File "/Users/czh/anaconda3/envs/mashi/lib/python3.7/site-packages/pyabsa-0.7.1.0-py3.7.egg/pyabsa/module/atepc/models/lcf_atepc.py", line 69, in forward File "/Users/czh/anaconda3/envs/mashi/lib/python3.7/site-packages/pyabsa-0.7.1.0-py3.7.egg/pyabsa/module/atepc/models/lcf_atepc.py", line 56, in get_ids_for_local_context_extractor File "/Users/czh/anaconda3/envs/mashi/lib/python3.7/site-packages/torch/cuda/__init__.py", line 164, in _lazy_init raise AssertionError("Torch not compiled with CUDA enabled") AssertionError: Torch not compiled with CUDA enabled

zhihao-chen commented 3 years ago

完整的traceback

------------------ 原始邮件 ------------------ 发件人: "yangheng95/PyABSA" @.>; 发送时间: 2021年6月15日(星期二) 中午1:56 @.>; @.**@.>; 主题: Re: [yangheng95/PyABSA] Torch not compiled with CUDA enabled (#29)

Can you show the stack trace? I didnt notice the occasion that using torch compiled without cuda, I will check and update soon.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

yangheng95 commented 3 years ago

你先直接在param_dict里指定'device=cpu'试试吧,代码我随后更新

zhihao-chen commented 3 years ago

ok, thanks

------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2021年6月15日(星期二) 下午2:10 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [yangheng95/PyABSA] Torch not compiled with CUDA enabled (#29)

你先直接在param_dict里指定'device=cpu'试试吧,代码我随后更新

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

yangheng95 commented 3 years ago

ok, thanks ------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2021年6月15日(星期二) 下午2:10 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [yangheng95/PyABSA] Torch not compiled with CUDA enabled (#29) 你先直接在param_dict里指定'device=cpu'试试吧,代码我随后更新 — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

主要是我这边没有安装过不支持cuda的torch,要另想办法测试

zhihao-chen commented 3 years ago

应该不是不支持cuda,而是哪一步有调用到torch的cuda。我在MacOS上跑的

------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2021年6月15日(星期二) 下午2:14 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [yangheng95/PyABSA] Torch not compiled with CUDA enabled (#29)

ok, thanks … ------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2021年6月15日(星期二) 下午2:10 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [yangheng95/PyABSA] Torch not compiled with CUDA enabled (#29) 你先直接在param_dict里指定'device=cpu'试试吧,代码我随后更新 — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

主要是我这边没有安装过不支持cuda的torch,要另想办法测试

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

yangheng95 commented 3 years ago

好的,现在可以了吗

yangheng95 commented 3 years ago

已修复,请使用pip安装最新发布的版本,pip install pyabsa==0.7.6.7,即可正常使用

yangheng95 commented 3 years ago

由于之前失误改动了ATEPC的默认参数,与上传的模型使用的参数不同,所以效果不佳,已上传的模型将会在最近更新

yangheng95 commented 3 years ago

Fixed in 0.8 version