Pytorch 已使用 Conda 安装,但调用时失败

ger*_*abs 3 conda deep-learning pytorch

我正在尝试安装pytorch以使用 BERT,但是按照此处找到的安装说明进行操作时: https: //pytorch.org/get-started/locally/我收到错误。

当我尝试初始化 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.
Run Code Online (Sandbox Code Playgroud)

我已按照说明进行操作,并在 Conda 提示符终端和当前工作目录中运行以下命令行:

conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch
Run Code Online (Sandbox Code Playgroud)

它看起来已经完成,但是当我尝试调用以下行时,我得到与开始相同的错误,就好像它根本没有安装一样。

谁能帮帮我吗?

编辑:

我用来执行 bert 的代码是:

model = BertForSequenceClassification.from_pretrained(r'C:\Users\441\bert\pytorch_model.bin', config = r'C:\Users\441\bert\config.json')
Run Code Online (Sandbox Code Playgroud)

小智 5

我遇到了同样的问题(相同的错误消息),并且在使用 conda list | 之后 grep torch 我也发现它在那里。对我有用的是,我重新启动了 jupyter 笔记本内核,错误就消失了。