I perform long calculations on a fast remote machine running the Mathematica kernel, where I followed the very useful guide Remote Kernel Strategies to establish the connection. I wonder, however, if there is a way to detach the Frontend from the running kernel in the same way as one can use the Linux program screen to keep remote shell sessions alive. I couldn't find anything similar for Mathematica, even though such a feature would be very convenient. Is there a way of doing that?
Many thanks,
Andreas.
Answer
This comes a little late, but this is my solution:
Remote Machine running linux with tmux (similar to screen but newer, should work with screen but I dont know the commands) and Mathematica 10 installed.
Local Machine running MacOS Yosemite with Mathematica 10.
Launch tmux in remote machine and execute Mathematica:
tmux
wolfram (executable to mathematica in terminal mode)
Now create a link with TCPIP protocol. Record the linkname="linkPort1@remoteIP,linkPort2@remoteIP" generated.
link=LinkCreate[LinkProtocol -> "TCPIP"]
LinkObject[linkPort1@remoteIP,linkPort2@remoteIP, 72, 1]Now in local machine, start Mathematica and go to Evaluation->Kernel Configuration Options -> Add... and fill out the window just as showed below.Dont forget to replace (insert remote ip ) by the remote machine ip address and insertLinkName by the link name that was generated above clic ok. Then open a new notebook and set the above created kernel as the notebooks kernel. Dont evaluate anything yet in this notebook.
Go back to your remote machine and run
$ParentLink=link
Finally go back to the notebook in your local machine and evaluate something:
$Version
So now you are running the kernel in the remote machine with the front end in your local machine.
To disconnect from the Kernel, evaluate the following in your notebook:
LinkClose /@ Links[]
At this point your kernel is still running in the remote machine. To reattach follow steps 2 through 5.
This could be automatized with a script. Also if you know that a port is always available, you could set the link with a persisten name so that you dont have to reconfigure the remote kernel each time you attach.
Comments
Post a Comment