Julia 语言添加远程核心

首先时解释一下我要作什么,我打算用julia进行一些并行计算。node

问题的起源是基于一个文档,文档连接在这里。这里面介绍了关于并行计算的一些配置方法和使用方法,好比能够在本地添加一些核心(processor),也能够添加远程的核心,这里面添加核心用的是addprocs函数。还要一些函数好比@spawn @spawnat @fetch就不细说了,看下文档便知一二,并且有中文文档能够看。ssh

如今我就来讲一下如何添加远程核心,我可以查到的资料有两个,一个是官方STL,另一个是邮件列表里的一个问题ide

文档是这样说的:函数

addprocs(machines; tunnel=false, dir=JULIA_HOME, sshflags::Cmd=``) → List of process identifiers

    Add processes on remote machines via SSH. Requires julia to be installed in the same location on each node, or to be available via a shared file system.

    machines is a vector of host definitions of the form [user@]host[:port]. A worker is started for each such definition.

    Keyword arguments:

    tunnel : if true then SSH tunneling will be used to connect to the worker.

    dir : specifies the location of the julia binaries on the worker nodes.

    sshflags : specifies additional ssh options, e.g. sshflags=`-i /home/foo/bar.pem` .

大概是说,要几个参数,第一个是machines,它是一个向量;第二个参数是tunnel,是个布尔值;第个是dir,它表明julia命令存放位置的一个字符串,好比/usr/bin;最后是一些sshflags,暂时用不到。fetch

因而咱们就能够用了,首先在终端输入juliaui

  • 你能够添加本地的processor,addprocs(3)就添加了三个本地核心。
  • 要添加远程的,应该用addprocs({"eccstartup@xxx.xxx.xxx.xxx[:port]"},tunnel=true,dir="/usr/bin")
    端口能够不指定,会提示输入远程的ssh密码。

这样就行了,试试nprocs()吧,很方便吧?google

相关文章
相关标签/搜索