Iva*_*van 15 wolfram-mathematica mathematica-8
当我尝试通过评估>并行内核配置在mathematica中配置远程内核时,我转到"远程内核"并添加主机.之后我尝试启动远程内核,其中只有一些启动(它们的数量不同).我得到一个像以下一样的消息.
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]}
Run Code Online (Sandbox Code Playgroud)
一旦它加载了所有内核,但通常不加载,只需要一个或两个远程内核.
Arn*_*ing 10
提供的信息非常少,因此这个答案可能不是100%有用.
始终要考虑的第一个问题是远程计算机上的许可.如果某些内核启动,但其他内核没有启动,则可能是因为该机器上的内核许可证已用完.本文的其余部分将假设许可不是问题.
连接方法
Mathematica中的远程内核接口默认采用rsh协议,这对许多环境来说都不是正确的选择,因为rsh不是一种非常安全的协议.
另一种选择是ssh,它得到了更广泛的支持.有许多ssh客户端,但我将专注于Mathematica附带的客户端,即WolframSSH.jar.这个客户端是基于Java的,它具有在Mathematica(Mac,Window和Linux)支持的所有平台上运行相同的额外好处.
为了避免必须为每个内核连接键入密码,可以方便地创建私钥/公钥对.私钥保留在您的计算机上,公钥需要放在远程计算机上(通常位于远程主目录的.ssh文件夹中).
要生成私钥/公钥对,可以使用WolframSSHKeyGen.jar文件,如下所示:
java -jar c:\path\to\mathematica\SystemFiles\Java\WolframSSHKeyGen.jar
Run Code Online (Sandbox Code Playgroud)
并按照出现的对话框上的说明进行操作.完成后,将公钥复制到远程计算机上的.ssh文件夹中.在我的情况下,我调用了键kernel_key并kernel_key.pub自动命名.
您现在可以从命令行测试连接,如下所示(使用ls远程计算机上的命令):
java -jar c:\path\to\mathematica\SystemFiles\Java\WolframSSH.jar --keyfile kernel_key arnoudb@machine.example.com ls
Run Code Online (Sandbox Code Playgroud)
如果这样做,你应该能够完成Mathematica方面的事情.
远程内核连接
要建立连接,您需要以下设置,即远程计算机的名称:
machine = "machine.example.com";
Run Code Online (Sandbox Code Playgroud)
登录名,通常是$ UserName:
user = $UserName;
Run Code Online (Sandbox Code Playgroud)
ssh二进制位置:
ssh = FileNameJoin[{$InstallationDirectory, "SystemFiles", "Java", "WolframSSH.jar"}];
Run Code Online (Sandbox Code Playgroud)
私钥如上所述:
privatekey = "c:\\users\\arnoudb\\kernel_key";
Run Code Online (Sandbox Code Playgroud)
内核的启动命令:
math = "math -mathlink -linkmode Connect `4` -linkname `2` -subkernel -noinit >& /dev/null &";
Run Code Online (Sandbox Code Playgroud)
将所有内容放在一起的配置功能:
ConfigureKernel[machine_, user_, ssh_, privatekey_, math_, number_] :=
SubKernels`RemoteKernels`RemoteMachine[
machine,
"java -jar \"" <> ssh <> "\" --keyfile \"" <> privatekey <> "\" " <> user <> "@" <> machine <> " \"" <> math <> "\"", number]
Run Code Online (Sandbox Code Playgroud)
这使用配置函数并将其定义为使用4个远程内核:
remote = ConfigureKernel[machine, user, ssh, privatekey, math, 4]
Run Code Online (Sandbox Code Playgroud)
这将启动内核:
LaunchKernels[remote]
Run Code Online (Sandbox Code Playgroud)
此命令验证内核是否全部已连接且远程:
ParallelEvaluate[$MachineName]
Run Code Online (Sandbox Code Playgroud)