Group Abstract Group Abstract

Message Boards Message Boards

Remote Kernel on Raspberry Pi

GROUPS:
I am trying to connect to a remote Pi using the RDK. I guess there has to be a way to get the Mathematica kernel running on the Pi - without invoking the GUI frontend (i am running headless over SSH). But I am unable to figure out how to do that - has anybody already got that going? Any help is appreciated.

Arvind
POSTED BY: Arvind Govindaraj
Answer
11 months ago
Arvind,

You can ssh to your remote Pi from your desktop and type 'wolfram' at the prompt: 
> wolfram
Wolfram Language (Raspberry Pi Pilot Release)
Copyright 1988-2013 Wolfram Research
Information & help: wolfram.com/raspi

In[1]:=
(Let me know if this is not what you are trying to do)
POSTED BY: Arnoud Buzing
Answer
11 months ago
Thanks Arnoud. I could get this working - but I was trying to get the Mathematica  kernel running from command line. I downloaded the Remote Development Kit ( from here: http://www.wolfram.com/raspberry-pi/) - which according to the description should allow remote execution of Mathematica code on a kernel running in the Pi (if my understanding is correct). When I try to run the provided Rasberry Pi example - I get an error message to the effect that it is not able to connect to a remote kernel on the Pi. It got me thinking that maybe I need to have an instance of the Mathematica kernel running on the Pi before I attempted to run any Mathematica code remotely. 
Please let me know if you have any pointers.

Arvind
POSTED BY: Arvind Govindaraj
Answer
11 months ago
Arvind, what is the output you get when you evaluate:

Options[$FrontEnd,EvaluatorNames]


on your (desktop) Mathematica?
POSTED BY: Arnoud Buzing
Answer
11 months ago
Hi Arnoud,

I'm having a similar problem as Arvind's when trying to run test code from the RDK.

The kernel is setup by the RDK automatically:
 {EvaluatorNames -> {
    "Local" -> {"AutoStartOnLaunch" -> True},
    "Raspberry Pi" -> {"RemoteMachine" -> True,
                       "TranslateReturns" -> True,
                       "AutoStartOnLaunch" -> False,
                       "Executable" -> "/usr/bin/wolfram",
                       "HostName" -> "192.168.1.110",
                       "RemoteLogin" -> "pi"}
    }
}
POSTED BY: Silvia Hao
Answer
11 months ago
Silvia,

And I assume that you can normally ssh to this machine (192.168.1.110) from your desktop using login 'pi' ?

Also note that the Wolfram Language on the RPi comes with a 4 license password, meaning that if you try to start a fifth 'wolfram' instance it will fail. You can check your process listing to make sure you don't have extra copies running (ps wuax | grep WolframKernel)
POSTED BY: Arnoud Buzing
Answer
11 months ago
Arnoud, 

Thanks for your really useful linux command. By using it checking the processes, it turned out when I was installing the RDK on my laptop, it was connected to a VPN network. I guess somehow this affected the installation, (maybe the IP address was hard coded in some configure file during installation?) so when I tried to use RPi remotely, Mathematica sent a start-remote-kernel shell command to RPi with the host IP 10.x.x.x rather than 192.168.x.x. I re-installed the RDK without VPN environment,
PacletUninstall["RemoteDevelopmentKit"]
PacletInstall["RemoteDevelopmentKit"]
and everything is great now!
POSTED BY: Silvia Hao
Answer
11 months ago
And in-explicably - it started working :-) Thanks for all the help.

Arvind
POSTED BY: Arvind Govindaraj
Answer
11 months ago
I'm not able to get the remote connection to work either.  I am running Mathematica 9.0.1.0 on a Windows 7 laptop, and have Mathematica also working on my Raspberry Pi (on Raspbian).  I can ssh to the RPi from my laptop and run the "wolfram" command without problems.  When I am directly using the RPi, I can invoke the Mathematica front end and get commands like Plot[ ] to work just as they do on my laptop.

I have installed the Remote Development Control Panel on my laptop's Mathematica, and configured the connection to my RPi over the LAN.

When on my laptop I run:
Options[$FrontEnd, EvaluatorNames]

I get this output:
{EvaluatorNames -> {"Local" -> {"AutoStartOnLaunch" -> True},
   "Raspberry Pi" -> {"RemoteMachine" -> True,
     "TranslateReturns" -> True, "AutoStartOnLaunch" -> False,
     "Executable" -> "/usr/bin/wolfram",
     "HostName" -> "192.168.0.162", "RemoteLogin" -> "pi"}}}

But when I try to create a "New Pi Notebook", I get this error:
Mathematica could not establish a connection to the kernel.
Kernel: Raspberry Pi.
Low-level MathLink error: Unknown internal error.

Should I change "AutoStartOnLaunch" to True?
POSTED BY: David DeBrota
Answer
11 months ago
Could the real author of the post under "Updating Name" let us know his name? We will fix the name then. Thanks!
POSTED BY: Moderation Team
Answer
11 months ago
Hi David,

Have you tried ps wuax | grep WolframKernel on your RPi right after you run your remote Pi Notebook? What does it say? Idon't think you should change the "AutoStartOnLaunch" to True.
POSTED BY: Silvia Hao
Answer
11 months ago
Here's the output requested... in between the two calls to ps wuax I tried to start a "New Pi Notebook" on my laptop:
pi@raspberrypi ~ $ ps wuax | grep WolframKernel
pi 2670 1.8 8.4 168812 37996 ? Sl Dec05 298:46 /opt/Wolfram/Wo
lframEngine/10.0/SystemFiles/Kernel/Binaries/Linux-ARM/WolframKernel -noinit -pw file /opt/Wolfram/WolframEngine/10.0/Configuration/Licensing/playerpass -mathlin
k -linkprotocol SharedMemory -linkconnect -linkname 4zfe4_shm pi 2835 1.9 9.8 173152 44168 ? Sl Dec05 302:01 /opt/Wolfram/Wo
lframEngine/10.0/SystemFiles/Kernel/Binaries/Linux-ARM/WolframKernel -mathlink -linkprotocol SharedMemory -linkconnect -linkname 5dgpy_shm
pi 9224 0.0 0.1 3544 880 pts/1 S+ 01:01 0:00 grep --color=au
to WolframKernel pi@raspberrypi ~ $ ps wuax | grep WolframKernel
pi 2670 1.8 8.4 168812 37996 ? Sl Dec05 298:47 /opt/Wolfram/WolframEngine/10.0/SystemFiles/Kernel/Binaries/Linux-ARM/WolframKernel -noinit -pwfile /opt/Wolfram/WolframEngine/10.0/Configuration/Licensing/playerpass -mathlink -linkprotocol SharedMemory -linkconnect -linkname 4zfe4_shm
pi 2835 1.9 9.8 173152 44168 ? Sl Dec05 302:02 /opt/Wolfram/WolframEngine/10.0/SystemFiles/Kernel/Binaries/Linux-ARM/WolframKernel -mathlink -linkprotocol SharedMemory -linkconnect -linkname 5dgpy_shm
pi 9226 0.0 0.1 3544 880 pts/1 S+ 01:02 0:00 grep --color=auto WolframKernel
pi@raspberry
POSTED BY: David DeBrota
Answer
11 months ago
Hi David,

I'm not sure what goes wrong, but I think your wolfram arguments are quite different from mine:
pi   2260  9.7  9.4 187804 42288 ?  Ssl  14:01   1:06
/opt/Wolfram/WolframEngine/10.0/SystemFiles/Kernel/Binaries/Linux-ARM/WolframKernel
-mathlink -LinkMode Connect -LinkProtocol TCPIP
-LinkName 58054@192.168.1.113,58055@192.168.1.113 -LinkHost 192.168.1.113

I think for a remote connection, shouldn't the -LinkProtocol be TCPIP, and there are IP addresses in -LinkName and -LinkHost?

I'm not a regular Linux user and never tried remotely using Mathematica before. I think we may have to wait for someone from WRI to check this.
POSTED BY: Silvia Hao
Answer
11 months ago
I'm recreating most of this almost a month later, and I can't reconcile the results I'm getting with the advice posted here.

To summarize:

1.) I have what I think is a functional installation on RPi. From the RPi command line, I can run ~$ wolfram and a Front Ended Mathematica from the RPi GUI ( ~$ startx).
2.) from a command line on the RPi, ~$ ifconfig reports an IP Address for the RPi of 10.0.1.18
3.) From a terminal window on a Mac on the network with the RPi
ssh 10.0.1.18 -l pi
, I can log on and run wolfram.

Confusion came when I downloaded Remote Development Kit and installed it on my Mac (running Mma 9.0.1, but other releases don't behave differently). Starting with the RPi booted to login, if I bring down the Remote Development Control Panel palette and click 'Configure Pi Connection,' I get a dialog that requests 'Network machine of Pi:' I'm guessing that this is the IP address of the RPi - the same one I used in the ssh above. The 'Login on Pi:" I suppose is my user name on the Pi, which has been left the default. When I click 'OK,' nothing obvious happens. I'll get to the things that evidently really happen later, but next I clicked on the 'Pi Test & Example Notebook' on the RDK Control Panel. The nb opens, and I run the $MachineName line. This opens a dialog box named 'Password For RemoteDevelopmentKitdial...' I don't have a clue what's expected here, but I've tried using the RPi's login password. The Mma line evidently executes, but there's no output.

About here, I looked at quitting the Mac kernel and starting over. What's hard to figure is that the Evaluation->Kernel->Quit Kernel yields a list with 'Local' and by now ten or so (grayed out) 'Raspberry Pi's (by now I had attempted the RDK setup process a couple of times.) The same list appears in the 'Notebook's Kernel,' here all black and all the RPi kernels checked. The list appearing under 'Default Kernel' is all black with 'Local' checked. 

So now I've unplugged the power to the RPi, closed Mma, reopened Mma and checked the kernel list. All there. Executing [font='courier new', courier, monospace]Options[$FrontEnd, EvaluatorNames] on a fresh copy of Mma on the laptop lists them all with forms like
"Raspberry Pi" -> {"RemoteMachine" -> True
,"TranslateReturns" -> True
,"AutoStartOnLaunch" -> False
,"Executable" -> "/usr/bin/wolfram"
,"HostName" -> "10.0.1.18"
, "RemoteLogin" -> RemoteDevelopmentKit`Private`dialogUserName$1324
}

I ran
PacletUninstall["RemoteDevelopmentKit"]
, the RDK disappeared from the Palette menu, but all the Kernels remain.

So I'm left without a clue how I got here, how to get rid of the spare kernels and how to connect remotely to Mathematica running on the Raspberry Pi.

TIA for any advice on any of this.

Fred Klingener
POSTED BY: Fred Klingener
Answer
10 months ago
Using the RDK fails for me, too.

After a delay of a minute or two, I get the following error after executing the $MachineName in the Pi test notebook.
The kernel Raspberry Pi failed to connect to the front end. (Error = MLECONNECT). You should try running the kernel connection outside the front end.

Here's some more info:
In[7]:= Options[$FrontEnd, EvaluatorNames]

Out[7]= {EvaluatorNames -> {"Local" -> {"AutoStartOnLaunch" -> True},
   "Raspberry Pi" -> {"RemoteMachine" -> True,
     "TranslateReturns" -> True, "AutoStartOnLaunch" -> False,
     "Executable" -> "/usr/bin/wolfram", "HostName" -> "192.168.1.15",
      "RemoteLogin" -> "pi"}}}

While I'm waiting on the remote kernel, I see the following when running "ps aux | grep Wolfram" in a remote ssh terminal to the RPi:
ps aux | grep Wolfram
pi       20401  0.9  4.5 115736 20404 ?        Ssl  11:53   0:00 /opt/Wolfram/WolframEngine/10.0/SystemFiles/Kernel/Binaries/Linux-ARM/WolframKernel -mathlink -LinkMode Connect -LinkProtocol TCPIP -LinkName 63865@172.29.111.182,63866@172.29.111.182 -LinkHost 172.29.111.182

Does something need to be configured on host RPi Wolfram kernel? Looking at the output of the ps aux | grep Wolfram command, the LAN IP address of 172.29.111.182 doesn't correspond to any machine on my LAN. The IP of the client (FrontEnd using the RDK) is 192.168.1.3. I should also add that I can ssh into the host RPi without any issues.
POSTED BY: David Grogg
Answer
10 months ago
I gave up on the RDK about three weeks ago, took another run at it with the arrival of my RPi camera, and I have some progress to report.

My last post in this thread outlined the failure to establish a notebook on Mma running on a Macbook but with the kernel running on the networked RPi. The symptom was a simple refusal to accept a login, (and that led to what I thought were particularly nasty loops that were hard to escape from.)

The crux problem, I've decided is the behavior of the Remote Development Control Panel (the dropdown palette). If I fail to replace the "Login on Pi" and expect the apparent default "pi" to be selected, subsequent attempts to use the kernel in a notebook fail.


The plausible reason can be seen by looking at Kernel>Evaluation>Kernel Configuration Options..., selecting the Raspberry Pi kernel I just created and choose to Edit it. At this stage,  that kernel configuration looks like


(The Remote host is the IP address I got from running ifconfig from the terminal on the Raspberry Pi) The entry under "Remote user:" looks suspiciously like a Module variable name, and if used at login would seemingly guarantee failure.

If I edit that entry explicitly to "pi", I can successfully log in.

 

Hth,

Fred Klingener
POSTED BY: Fred Klingener
Answer
10 months ago
The RDK will evidently find a named Raspberry Pi on the network and configure it. This should make things much easier if the network gets shuffled and addresses are reassigned.

The following setup evidently works fine from Mathematica menu bar on the MacBook, selecting the new kernel under Evaluation>Kernel Configuration Options>Edit...


Another issue occasionally discussed on this forum is whether or not the wolfram program must be run from sudo. So far, I haven't been able to detect a difference in notebook behavior. I don't have the background to even know what questions to ask, so I hope someone can explain it.

Hth,
Fred Klingener
POSTED BY: Fred Klingener
Answer
10 months ago
I guess the method described in the last message (using the computer name to specify location of the Remote Host on the network) only works on even days or for some other inscrutable reason. The connection failed this morning, so I'm back to the numerical IP address and will stay there.

Hth,
Fred Klingener
POSTED BY: Fred Klingener
Answer
10 months ago
POSTED BY: Yukihiro KOBUNA
Answer
6 months ago
The remote kernal setup is very particular. If you don't get it just right the local kernal reports the following error:  SSH could not find the machine on which to launch the kernel 'Raspberry Pi'.

Under Basic Option:
Machine Name: raspberrypi
Remote Login: pi
Kernel Program: /usr/bin/wolfram

raspberrypi is the name of the machine and I added an entry in my windows host file with the ip address. For the Remote Login: I included the password as pi@raspberry and this caused the error message so it should be just pi. The RDK will ask you to confirm the connection and ask for a password.
POSTED BY: Jay Morreale
Answer
5 months ago
I tried again to get a connection to a remote kernel, without success.  This time I tried running M on an ubuntu 14.04 AMD x86-based desktop machine (named "octopus"), connecting over a LAN to a RaspberryPi running Raspbian.  Here's what works:

octopus can ping RPi
RPi can ping octopus
from octopus, I can use SSH to start a console session running on the RPi... the RPi user is pi@raspberrypi
from octopus, I can also use SSH to browse files/directories on the RPi
M front end and kernel run just fine on RPi
(text only) Wolfram Language works on RPi, both when I invoke it locally and remotely (via SSH console session)
M front end and kernel run just fine on octopus
the RDK has been installed into M on octopus... the palette comes up as it should

Now, I try to connect the M front end running on octopus to a kernel running on RPi.  No luck.

So I have now tried connecting to this same RPi from a Windows-based laptop and an ubuntu-based desktop, with no success either way.

I welcome any suggestions!
POSTED BY: David DeBrota
Answer
5 months ago