Using PyCharm to debug Pytorch model on GCE, AWS or Azure

Hello everyone,
I know my question is not directly related to deep learning or Pytorch, but I have found this community so helpful and one time more I need your help.

I have implemented a model using Pytorch, but I do not have access to GPU on my local environment and using Google Colab is so frustrating because of lack of access to debugging utilities.

Now I come across this idea to use Google Preemptible Compute Engine or Amazon EC2 Spot or other cloud services, to test my implementation.
The problem is I am not sure about connecting cloud runtime to my local IDE and run debugs by using breakpoints in my local IDE.

I have read about this in the docs on clouds and PyCharm and it seems it is possible, but I am not sure about it.

Thanks for your replies.

It is possible to do remote debugging from PyCharm Professional to the cloud instances through ssh connection. And in addition to GCP and AWS, it works with Colab too. Done that.

Thanks for your reply.

But, are you sure about Google colab? Because, based on the documentation, you can control your local environment through colab, not controlling colab through your local environment.

I have googled a lot, but I did not find any procedure to make it happen.
Can you please provide any documenation about using Google colab as a remote debugger?

Thank you

Yes, I’m sure. Done that several times. Having free K80 GPU right in PyCharm is super handy when you want to make your code GPU proofed.

Configuration is tricky, multistep process, but doable. The main problem is that Colab VM instance is hidden behind a firewall. But inside of the virtual machine lives Linux Ubuntu, co we can do some hocus-pocus.

High level approach would be to:

  1. Create “setup ssh forwarding” jupyter notebook in Google Colab. You can use my configuration notebook as a template for yours - demo_colab_ssh_access. Make sure you generate and then use your RSA access keys, customize port numbers, etc.
  2. Setup and start ssh server on running Colab VM instance.
  3. Establish ssh tunnel from Colab VM instance to some server on the internet, forward traffic from port 22 to some port there and…
  4. Expose this port for external access. portmap.io service allows one port forwarding for free.
  5. From now on you have ability to ssh from your computer to Colab VM instance and you can proceed with configuring remote interpreter via ssh in PyCharm.
  6. Every time you start new Colab session you’ll just replay “setup ssh forwarding” jupyter notebook and voila :slight_smile:

Ping me if you get stuck.

1 Like

Hi again,
Sorry, I got stuck in the final step.

I do not know what I should write in the Allowed IP section. By the way, I get this error Every time I try to make a tunnel from my local machine to google Colab:

Warning: remote port forwarding failed to listen port XXXX

XXXX is the port portmap.io assigned to my rule.

Leave it empty for now.

I don’t know which step doesn’t work for you. But… it took me best part of a year to master port forwardings, anyway :wink:

I can help you to debug this interactively, preferably through audio + screen sharing. Would you like to do it? Hangouts or Skype perhaps?

Ow, Actually, I am taking this semester final tests, meanwhile I do not have access to any reliable internet connections at the university unfortunately (I know it is weird but it is the truth!).

I will try more next time and if I really have no other options to proceed, I will let you know.

I am so appreciated for your help.
Thanks again.