MATLAB Answers

Using remote matlab on a cluster: Lost connection but job keeps calculating. How to reopen matlab gui?

2 views (last 30 days)
Just lost connection while a script on matlab was running remotely on a linux cluster. I was running it from the remote matlab GUI just like I would do locally. Suddently I lost connection and that window closed, but reconnecting again to the cluster I can see the script keeps running with "top" command. Is there any way to reopen the matlab GUI just where I left it and keep seeing progress on the console?

  3 Comments

Bjorn Gustavsson
Bjorn Gustavsson on 4 Jun 2020
For future work, I suggest you start running matlab either with vnc-server-viewer (for the full gui-experience) or simply through screen running in an x-term. Those methods work well for interuption-sensitive connections.
Good luck this time!
Jesús Gutiérrez
Jesús Gutiérrez on 4 Jun 2020
Thanks for your responses!
Im running throuh a mobaxterm terminal. I introduce "module load matlab" and next "matlab", just after that a matlab window opens just like when you use regular matlab on a windows machine. There I can run my scripts.
The problem comes when I loose connection and therefore the matlab window closes. When I reconnect to the cluster I can see that the script keeps running with the resource manager but I don't know how can I reopen the Matlab window I had in order to keep seeing what the console promts.

Sign in to comment.

Accepted Answer

Jason Ross
Jason Ross on 4 Jun 2020
The short answer: you can't get it back. It sounds like it's using X forwarding to send the GUI from the remote machine to your local machine.
As Bjorn Gustavsson says, if you are on a connection that has a high chance of dropping out or being ended somehow, you need to keep the display at the remote end if you want to keep this workflow. For Linux that means VNC (or something very much like it) if you want the GUI, or something like screen (or tmux) if you just want it in the terminal session.
Other approaches that may work:
  • Use one of the support packages / add-ins for the different cluster types we integrate with, installed on your local machine. This assumes that your cluster admins have means of supporting this, and a bunch of other things. Most importantly it moves the network connection out of the "job" of updating display -- only the submit/status/data comes back over the wire. As I mentioned earlier, this assumes a number of things about your environment, setup, etc. So it may not be workable for you.
  • Instead of running an interactive job from the console, submit jobs using the batch command. This will submit a job to the cluster whose results you can retrieve later. If you lose connection to the cluster you can reconnect/restart and then find the job and check the results.

  2 Comments

Jesús Gutiérrez
Jesús Gutiérrez on 4 Jun 2020
Thanks a lot, I will follow your recommendations next time. Just got installed on my university's cluster Matlab and everything is new.
Jason Ross
Jason Ross on 4 Jun 2020
You might ask the cluster admins what their recommended approaches are, I can imagine this is a relatively common question they get -- X forwarding has been around a long time (and I remember thinking how cool it was the first time I saw it) but it has a number of deficiencies like the one you saw. There are plenty of solutions that have been developed in the meantime, it's just a question of what your admins support/recommend.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by