7
$\begingroup$

I've reviewed the following posts:

Connecting two Raspberry Pi's using MathLink

remote kernel through SSH

How to connect the front end of one raspberry pi with the kernel of another

But have been unsuccessful in launching a remote kernel on a Pi from another Pi's front end.

I completed step 1 from the last referenced post and can access the remote Pi without a password using the terminal window but every other step fails once confined to the front end.

mathl[link_] := "wolfram -mathlink -linkmode Connect -linkprotocol TCPIP 
 -linkname " <> link <> " -subkernel -noinit &< /dev/null &";
machine = "169.254.160.100";
link = LinkCreate[LinkProtocol -> "TCPIP"];
linkname = First@link;
cmd = "ssh " <> $UserName <> "@" <> machine <> " \"" <> mathl[linkname] <> "\"";

The link created is 127.0.0.1 which doesn't work and seems wrong so I forced it to use the following:

mathl[link_] := "wolfram -mathlink -linkmode Connect -linkprotocol TCPIP 
 -linkname " <> link <> " -subkernel -noinit &< /dev/null &";
machine = "169.254.160.100";
link = LinkCreate["@169.254.160.120,@169.254.160.120,",LinkProtocol -> "TCPIP"];
linkname = First@link;
cmd = "ssh " <> $UserName <> "@" <> machine <> " \"" <> mathl[linkname] <> "\"";

169.254.160.100 is the remote Pi and 169.254.160.120 is the local Pi

No matter what I try it seems to hang on LinkWrite[link,Unevaluated@{$MachineName,Now[]}]; of

process = StartProcess[$SystemShell];
    WriteLine[process,cmd];
    LinkWrite[link,Unevaluated@{$MachineName,Now[]}];
LinkRead@link
$\endgroup$

1 Answer 1

5
$\begingroup$

It turns out that remote kernel through SSH was the most useful guide. Setting up the remote Kernels manually was more succsessful compared to using FrontEndTokenExecute["PreferencesDialog"]

In addition, I connected the boards using the on-board wireless as opposed to the LAN connection which for some reason helped.

The following code launches 4 local and 4 remote Kernels (assuming you've done ssh-keygen, ssh-copy-id pi@<remote> - reference):

Needs["SubKernels`RemoteKernels`"]

Parallel`Palette`menuStatus[]
LaunchKernels[4]

user = "pi";
machine = "<remote ip>";
number = 4;(*number of parallel kernels to launch*)

ssh = "export LD_LIBRARY_PATH=;ssh";
mathl[link_] := "wolfram" <> " -mathlink -linkmode Connect `4` 
                -linkname `2` -subkernel -noinit >& /dev/null &";

remote = SubKernels`RemoteKernels`RemoteMachine[machine, 
  ssh <> " " <> user <> "@" <> machine <> " \"" <> mathl[linkname] <> 
   "\"", number]

Print[remote // InputForm]
kerns = LaunchKernels[remote]

ParallelEvaluate[$MachineName]

The following maxes all cores on both local and remote:

ParallelTable[Prime[100000000000], {8}];

Now that this works, I'm adding two more remote Pi boards to use the full 16 Kernel license!

$\endgroup$

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.