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.
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.
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?
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:
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.
Setup and start ssh server on running Colab VM instance.
Establish ssh tunnel from Colab VM instance to some server on the internet, forward traffic from port 22 to some port there and…
Expose this port for external access. portmap.io service allows one port forwarding for free.
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
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.
Thank you for your tremendous contribution. I encountered one problem in configuring remote interpreter in Pycharm. Actually, I added remote interpreter but I got an error:
Indicated packet length 1416128883 too large.
I tried removing the line of ls -l /root/.ssh, but not working.
I also added a line of [[ $- == i ]] || return at the beginning of .bashrc. It was not working either.
Also from me a big thank you for this guide! I tried following your guide, but got stuck and hoped that you could help me out? It seems that I was able to successfully execute the instructions of “demo_colab_ssh_access”. Because when I run the cell with
Warning: Permanently added 'wojtekcz-53525.portmap.io,<three digits>.<three digits>.<three digits>.<two digits>' (ECDSA) to the list of known hosts., which I take as it having worked successfully!
(of course, I have replaced “53525”, “wojtekcz” and “first” appropriately, as well as the value for “fn_private_key_pem”)
The next step in your guide was to follow “configuring remote interpreter via ssh in PyCharm” and this is where I got stuck. I tried the “New server configuration” option with <three digits>.<three digits>.<three digits>.<two digits> as my Host, 22 as port and wojtekcz-53525.portmap.io as my username. As my authentication option, I picked “Key pair (OpenSSH or PuTTY):” with my “private_key_pem”, but got
Connection to wojtekcz-53525.portmap.io@<three digits>.<three digits>.<three digits>.<two digits>:22 failed:
Timeout expired
as an error. And thus, I have been scratching my head what I am doing wrong.
@Cdfghglz I hope it’s okay to ask you, since wojtekcz doesn’t seem to be active on the pytorh forum anymore. Since it seems that you managed to follow wojtekcz’s guide, could I ask you for help with the problem I encountered, described in the post previous to this one to this topic?