15

Evaluation>Parallel Kernel Configuration を介して Mathematica でリモート カーネルを設定しようとすると、[Remote Kernel] に移動してホストを追加します。その後、リモート カーネルを起動しようとしましたが、一部しか起動されません (数はさまざまです)。そして、次のようなメッセージが表示されます。

KernelObject::rdead: リモート [nodo2] 経由で接続されたサブカーネルが停止しているように見えます。>> LinkConnect::linkc: LinkObject[36154@192.168.1.104,49648@192.168.1.104,38,12] に接続できません。>> General::stop: この計算中、LinkConnect::linkc のそれ以降の出力は抑制されます。>>

これを機能させる方法はありますか?

リモートカーネルの一部をロードすることがありますが、すべてをロードするわけではないことを考慮してください。前もって感謝します。


これは私の出力です$ConfiguredKernels // InputForm

{SubKernels`LocalKernels`LocalMachine[4], 
 SubKernels`RemoteKernels`RemoteMachine["nodo2", 2], 
 SubKernels`RemoteKernels`RemoteMachine["nodo1", 2], 
 SubKernels`RemoteKernels`RemoteMachine["nodo3", 2], 
 SubKernels`RemoteKernels`RemoteMachine["nodo4", 2], 
 SubKernels`RemoteKernels`RemoteMachine["nodo5", 2]}

すべてのカーネルをロードすると、通常はロードされず、1 つまたは 2 つのリモート カーネルだけがロードされます。

4

1 に答える 1

10

There is very little information given, so this answer may not be 100% useful.

The first issue to always consider is licensing on the remote machine. If some kernels launch, but others don't, it is possible you have run out of licenses for kernels on that machine. The rest of this post will assume licensing is not the issue.

Connection Method

The remote kernel interface in Mathematica by default assumes the rsh protocol, which is not the right choice for many environments, because rsh is not a very secure protocol.

The other option is ssh, which is much more widely supported. There are many ssh clients, but I will focus on a client included with Mathematica, namely WolframSSH.jar. This client is java based, which has the added benefit of working the same on all platforms supported by Mathematica (Mac, Window and Linux).

To avoid having to type a password for every kernel connection, it is convenient to create a private/public key pair. The private key stays on your computer and the public key needs to be placed on the remote computer (usually in the .ssh folder of the remote home directory).

To generate a private/public key pair you can use the WolframSSHKeyGen.jar file, like so:

java -jar c:\path\to\mathematica\SystemFiles\Java\WolframSSHKeyGen.jar

and follow the instructions on the dialogs that come up. When done, copy the public key to the .ssh folder on the remote machine. In my case, I called the keys kernel_key and kernel_key.pub was automatically named that way.

You can now test the connection from a command line, like so (using the ls command on the remote machine):

java -jar c:\path\to\mathematica\SystemFiles\Java\WolframSSH.jar --keyfile kernel_key arnoudb@machine.example.com ls

If this works, you should be able to finish on the Mathematica side of things.

Remote Kernel Connection

To make a connection you need the following settings, the name of the remote machine:

machine = "machine.example.com";

The login name, usually $UserName:

user = $UserName;

The ssh binary location:

ssh = FileNameJoin[{$InstallationDirectory, "SystemFiles", "Java", "WolframSSH.jar"}];

The private key as described above:

privatekey = "c:\\users\\arnoudb\\kernel_key";

The launch command for the kernel:

math = "math -mathlink -linkmode Connect `4` -linkname `2` -subkernel -noinit >& /dev/null &";

A configuration function to put everything together:

ConfigureKernel[machine_, user_, ssh_, privatekey_, math_, number_] :=
 SubKernels`RemoteKernels`RemoteMachine[
  machine,
  "java -jar \"" <> ssh <> "\" --keyfile \"" <> privatekey <> "\" " <> user <> "@" <> machine <> " \"" <> math <> "\"", number]

This uses the configuration function and defines it to use 4 remote kernels:

remote = ConfigureKernel[machine, user, ssh, privatekey, math, 4]

This launches the kernels:

LaunchKernels[remote]

This command verifies if the kernels are all connected and remote:

ParallelEvaluate[$MachineName]
于 2011-11-11T20:20:19.047 に答える