1
$\begingroup$

I've seen many questions regarding the connection to a Linux machine from a Windows one, but I need to do the opposite.

Situation: I have Mathematica on my Linux laptop (A) and I want to run a remote kernel on my Windows desktop (B) (which also has Mathematica)

Current solution: On A I have a kernel that opens in LinkMode so when I execute something it gives me a port and IP address of my machine. Then on B I use the LinkConnect function that allows me to run my computations on B's kernel.

Things to improve: I want to be able to do this automatically. One annoying part of this solution is that the numbers N,M that I use in the LinkConnect function (LinkConnect["N@IP-address,M@IP-address",LinkProtocol->"TCPIP") always change, so I have to retype them every time.

The other problem is that sometimes I use parallel functions e.g. ParallelTable[] but using this solution doesn't allow me to execute multiple kernels on B.

Questions: I think Mathematica comes with a way to do this connection in the background using Remote Kernels, but I don't know how to connect A with B using that.

  • Is it possible to connect from Linux to Windows using Remote Kernels? if so, how?
  • Will this allow me to execute parallel kernels in B?
$\endgroup$
1
$\begingroup$

The answer to my question is based on the answer to How to configure parallel remote kernels in Mathematica?. The solution is:

  • Install Cygwin on the B machine to have ssh. For a password-less access we need to copy the public keys of A to the autorized_keys file in B.
  • In A open Mathematica, go to Preferences->Parallel->Remote Kernels and hit Enable Remote Kernels. There we input the hostname of B, select the number of Kernels we want and check Enable
  • Check Use custom launch command and paste the following text in the box:

    java -jar
    "/usr/local/Wolfram/Mathematica/10.0/SystemFiles/Java/WolframSSH.jar" 
    `3`@`1`  "/cygdrive/c/Program\\ Files/Wolfram\\
    Research/Mathematica/10.0/math.exe -mathlink -linkmode Connect `4` 
    -linkname '`2`' -subkernel -noinit >& /dev/null &"
    

    where /usr/local/Wolfram/Mathematica/10.0/ is the installation path of Mathematica in A and c:\Program Files\Wolfram Research\Mathematica\10.0 is the installation path in B.

Then writing

ParallelEvaluate[$MachineName]

outputs

{"xxxxx-laptop", "xxxxx-laptop", "xxxxx-pc", 
"xxxxx-pc", "xxxxx-pc", "xxxxx-pc"}

which corresponds to 2 local Kernels from A and 4 remote Kernels on B.

The advantage of using this method is that all these Kernels can be used for parallel computation (which answers my second question).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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