简体   繁体   中英

How to run a google Colab Notebook from terminal?

Suppose I have a Google Colab Notebook in an address like below:

https://colab.research.google.com/drive/XYZ

I want to keep it running for 12 hours, however, then again I want to turn my computer off. As a solution, I can connect to our Lab's server via ssh. The server is running all the time. I would like to know if it's possible that I load and run the notebook there? I found a solution to connect to a Google Colab Session via ssh ( colab_ssh package), but it again needs a running Colab Session.

I also tried to browse the link with lynx , but it needs login and this isn't supported by this browser.

Yes, it is possible. You would first need to download your colab notebook as an .ipynb file, then copy it to your server. Then, you can follow one of the guides on how to connect to a remotely running jupyter notebook session, like this one. All you need is the jupyter notebook software on your server, and an ssh client on your local computer.

Edit: I forgot to mention this: To keep your session alive even after closing the ssh connection, you can use tools like screen . The link provides more detailed explanation, but the general idea is that after connecting to your server, first you need to create a session like this:

screen -S <session_name>

which will create a new session and attach you to it (which is the term used when you are inside a session). Then, you can fire up your jupyter notebook here, and it will keep running even after closing the ssh connection. (You just have to make sure you don't kill the screen session using Ctrl+a followed by k )

Now, you have an indefinitely running jupyter notebook session on your server. You can connect to it via

ssh -N -f -L localhost:YYYY:localhost:XXXX remoteuser@remotehost

as mentioned in the first linked guide, use the browser to run a code cell on your jupyter notebook, and then turn off your laptop without worrying about interrupting your notebook session.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM