我正在尝试安装使用BERT的pytorch,但是当按照这里的安装说明操作时:https://pytorch.org/get-started/locally/ I遇到一个错误。
当我尝试初始化BERT模型时,我得到了以下错误:
ImportError:
BertForSequenceClassification requires the PyTorch library but it was not found in your environment.
Checkout the instructions on theinstallation page: https://pytorch.org/get-started/locally/
and follow the ones that match your environment.我已经按照说明在Conda提示终端和当前工作目录中运行了以下命令行:
conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch它看起来像是完成了,但当我尝试调用以下代码行时,我得到了与start相同的错误,就好像它根本没有安装一样。
有谁能帮帮我吗?
编辑:
我用于执行bert的代码是:
model = BertForSequenceClassification.from_pretrained(r'C:\Users\441\bert\pytorch_model.bin', config = r'C:\Users\441\bert\config.json')发布于 2021-06-14 22:57:48
我也有同样的问题(同样的错误消息),在使用conda list | grep torch之后,我也发现它就在那里。对我来说起作用的是,我重新启动了jupyter笔记本内核,错误消失了。
https://stackoverflow.com/questions/65921244
复制相似问题