pytorch - 谷歌 Colab : "Unable to connect to the runtime" after uploading Pytorch model from local

标签 pytorch google-colaboratory data-persistence

我正在使用一种简单(不一定有效)的方法来保存 Pytorch 模型。

import torch
from google.colab import files

torch.save(model, filename) # save a trained model on the VM
files.download(filename) # download the model to local

best_model = files.upload() # select the model just downloaded
best_model[filename] # access the model

Colab 在执行最后一行时断开连接,并点击 RECONNECT标签总是显示 ALLOCATING -> CONNECTING (失败,左下角显示“无法连接到运行时”消息)-> RECONNECT .同时,执行任何一个单元格都会给出错误消息“无法执行单元格,无法向运行时发送执行消息:[object CloseEvent]”

我知道它与最后一行有关,因为我可以成功连接到其他不执行该操作的 google 帐户。

为什么会发生?似乎已执行最后一行的 google 帐户无法再连接到运行时。

编辑:

一晚后,我可以在 session 到期后重新连接 google 帐户。我刚刚尝试了评论中的方法,发现只是 files.upload() Pytorch 模型会导致这个问题。上传完成后,Colab 会断开连接。

最佳答案

尝试禁用您的广告拦截器。为我工作

关于pytorch - 谷歌 Colab : "Unable to connect to the runtime" after uploading Pytorch model from local,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50675219/

相关文章:

python - LSTM 实现/过拟合

pytorch - 如何在多次运行中重现 RNN 结果?

python-3.x - Colab 中的 Python 脚本不断抛出错误消息 : IndentationError: unindent does not match any outer indentation level

python - 从 google colab 访问 google 驱动程序 - 失败(“意外错误响应 :

python - 无法在 google colab 中安装 textract

java - Java中如何保证跨类和方法的数据持久化?

ios - 使用 Couchbase Lite 在 Mac 应用程序中保存树形数据结构

pytorch - 将 PyTorch 模型转换为 TorchScript 时出错

java - 应用程序数据持久性框架/库?

python - 如何将pytorch张量中的维度中的最小k个元素设置为特定值?