title: Google Colab: "Unable to connect to the runtime" after uploading Pytorch model from local
body: <p>I am using a simple (not necessarily efficient) method for Pytorch model saving.</p>
  
  
  
  <pre class="lang-python prettyprint-override"><code>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
  </code></pre>
  
  <p>Colab disconnects during execution of the last line, and hitting <code>RECONNECT</code> tab always shows <code>ALLOCATING</code> -> <code>CONNECTING</code> (fails, with "unable to connect to the runtime" message in the left bottom corner) -> <code>RECONNECT</code>. At the same time, executing any one of the cells gives Error message "Failed to execute cell, Could not send execute message to runtime: [object CloseEvent]"</p>
  
  <p>I know it is related to the last line, because I can successfully connect with my other google accounts which doesn't execute that.</p>
  
  <p>Why does it happen? It seems the google accounts which have executed the last line can no longer connect to the runtime.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>One night later, I can reconnect with the google account after session expiration. I just attempted the approach in the comment, and found that just <code>files.upload()</code> the Pytorch model would lead to the problem. Once the upload completes, Colab disconnects. </p>