I have use remote kernel almost every day, but I guess I never understand how it works. I have basically two questions:

  1. How do we manually setup and use one kernel as a remote kernel to the other?

Suppose we have a two machines and for each machine I have a terminal opened.

Machine 1:

[user@001 ~]$

Machine 2:

[user@002 ~]$ 

Now I launch a math kernel on each machine

Machine 1:

[user@001 ~]$math

Machine 2:

[user@002 ~]$math

Is it possible to use the kernel on machine 2 as a remote kernel for machine 1, without close the kernel and restart again? Assuming the communication between the two machines are good, and the ip address for the two machines are and From the documentation I know that one kernel will create mathlink and be listening, and the other kernel will try to connect to the created link. But how does this work in detail, for instance, could you show me the steps to connect the two in the above example?

  1. In the documentation here, it shows the steps to mannully connect to the remote kernel. Could you example how does that work? I can use the remote kernel by following the steps there, but I don't quiet understand how it works.

For example, what does the "Arguments for MLOpen" used for? For instance, my default value is

-LinkMode Launch -LinkProtocol SharedMemory -LinkName "'/Applications/Mathematica.app/Contents/MacOS/MathKernel' -mathlink" -LinkOptions 3

Could you explain what each option and the argument mean? And sometimes I see option like "LinkHost" which seems to not well documented. What does LinkHost mean, does it mean the host the local kernel is at or the host of the remote kernel?

enter image description here


1 Answer 1


There is a very useful paper by David Wagner (point to me by halirutan) that explains all the details of how this work.

A simple example illustrates the process:

start a link on local computer, this will make the kernel listen on some ports

localIn[1]:= linktoremote = LinkCreate[LinkProtocol->"TCPIP"]
localOut[1]= LinkObject[[email protected],[email protected], 59, 1]

on remote computer, connect to this port on the local computer

remoteIn[1]:= linktolocal = LinkConnect["[email protected],[email protected]",LinkProtocol->"TCPIP"]
remoteOut[1]= LinkObject[[email protected],[email protected], 59, 1]

Then the link will establish, and we can read and write to the link on both sides

write to the link on the remote computer

remoteIn[2]:= LinkWrite[linktolocal,"Hello from remote"]

read the link on the local computer

localIn[2]:= LinkRead[linktoremote]
localOut[2]= Hello from remote

write to the link on the local computer

localIn[3]:= LinkWrite[linktoremote,"Hello from local"]

read the link on the remote computer

remoteIn[3]:= LinkRead[linktolocal]
remoteOut[3]= Hello from local
  • $\begingroup$ This doesn't work for me. $\endgroup$
    – M.R.
    Jul 26, 2016 at 0:17
  • $\begingroup$ @M.R. What version are you using? It works for me on version 10.1. I'm not sure whether they have changed something recently. $\endgroup$ Jul 26, 2016 at 3:05
  • $\begingroup$ I have 10.4.1, my remote is in EC2, never ever gotten a remote kernel to work there. $\endgroup$
    – M.R.
    Jul 26, 2016 at 3:53
  • $\begingroup$ I've never had experience with EC2. But maybe you could try the tunnel package. $\endgroup$ Jul 26, 2016 at 14:12
  • $\begingroup$ The link has died, but can be found on the Internet Archive here. $\endgroup$ Aug 23, 2023 at 10:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.