3
$\begingroup$

The answer to an earlier question,

Computers running Wolfram Lightweight Grid Manager won't fall asleep,

left me with a new problem. To review, I have a computing environment comprised of:

  • 27" iMac with dual cores running Mac OS X 10.6.8 and
  • 2 XServes each with 2 quad cores running Max OS X Server 10.6.8
  • All networking by ethernet to a Time capsule.

As this question has more general application than the earlier question, I thought it merited its own post.

...

I need to launch and shut down a service (in my case Wolfram Lightweight Grid Manager but this really applies to any service, program, or application) which needs to run on a server (or more generally, any other machine) attached to my network (or again more generally, any network to which one has authorized access).

So, ideally I'd like to do the following:

  • Access and log on to (a) remote computer(s) on a local network directly from Mathematica;

  • Launch a script on the remote computer that will in turn launch Wolfram Lightweight Grid Manager;

  • Launch available kernels;

  • Run parallel processing code;

  • Close remote kernels; and

  • Launch a script on the remote computer to close Wolfram Lightweight Grid Manager.


Can I do all of this from within Mathematica?

How?


Run[] enables one to run a command line program:

Run[] example

But how do I get to a remote machine, especially as it does not likely have a fixed IP address? ;-(

I would appear to need a way to identify machines on the network (I do have machine names and log on credentials).

I've very rarely done this sort of thing.


Could a script launched locally by the Run[] function access the remote machines and launch a script on them?


That would make it easy.

References or examples welcome.

My Unix script never amounted to much, so any guidance welcome.

It also, occurs to me that one could do this via JLink, but as the little I knew of Java has generally drifted out of my memory a more direct solution would do me better.

$\endgroup$
7
  • $\begingroup$ Not having a fixed IP is a problem. If the machine did have one, you could log in with ssh an execute commands. To execute command x on machine y, logging in as user z, you need to execute ssh z@y x from a command shell. Normally this prompts for a password, but if you use public key authentication, entering a password can be avoided, and you can automate everything completely. $\endgroup$
    – Szabolcs
    Commented Jul 5, 2012 at 18:44
  • $\begingroup$ Anyway to do the SSH using the server's names on the network? $\endgroup$
    – Jagra
    Commented Jul 5, 2012 at 18:50
  • $\begingroup$ Could I programmatically ping the XServes' names and get back the current IP addresses. Maybe not reliable. Just trying to think this through. $\endgroup$
    – Jagra
    Commented Jul 5, 2012 at 19:01
  • $\begingroup$ @Jagra If the names are associated with the current IP address, i.e. you can ping them, then you don't need the IP address. You could run a local nameserver to lookup the IP addresses, or set all the machines to fixed IPs. $\endgroup$ Commented Jul 5, 2012 at 19:09
  • $\begingroup$ @image_doctor - Thanks for the suggestion. I also discovered that one can set up a "DHCP reservation" on the TimeCapsule using an Airport Utility. Then say, using a client ID one can easily change things if one ever replaces a server. Also suggested to me, typing the MAC address could work. Still lots to figure out to get this to work. $\endgroup$
    – Jagra
    Commented Jul 5, 2012 at 20:32

1 Answer 1

3
$\begingroup$

Once setup you should be able to do all of what you want from Mathematica without resorting to shell scripts.

This isn't Apple specific, but hopefully this will get you most of the way and uses the Remote Kernel method rather than the lightweight grid manager:

  1. Create an ssh key if you haven't already, using ssh-keygen

  2. Copy that key to all the remote hosts you want to use using ssh-copy-id hostname Check you can login without supplying a password to each host with ssh hostname

  3. Define the remote machines to be used and the number of kernels using menu item: Evaluation->ParallelKernelConfiguration: [TAB] Parallel [TAB] Remote Kernels

which requires a hostname and possibly a custom launch command. I needed to specify the fullpath the Mathematica kernel, which in my case was /usr/local/bin/math giving:

    ssh -x -f -l `3` `1` /usr/local/bin/math -mathlink -linkmode Connect `4` -linkname '`2`' -subkernel -noinit
  1. The kernels you have defined using this method, as well as your local kernels, are then held in $ConfiguredKernels. They can all be launched using LaunchKernels[]

  2. The control of code execution can then be done with the usual Mathematica parallel evaluation functions and the kernels can be closed jointly or separately using CloseKernels[]. The current running kernels can be listed by Kernels[].

$\endgroup$
2
  • $\begingroup$ I tried to fix the command line formatting problem, but I don't know if I got it right. Please check it. $\endgroup$
    – Mr.Wizard
    Commented Jul 9, 2012 at 14:45
  • $\begingroup$ @Mr.Wizard Thanks, it looks correct to me, that was beyond my formatting capabilities :) $\endgroup$ Commented Jul 9, 2012 at 14:56

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.