Ejemplo n.º 1
0
 def test_lsf_config_processing(self):
     vars = {'LSB_MCPU_HOSTS': 'hostA 2 hostB 1', 'FDUST_GPU_PER_CORE': 1}
     random.seed(1234)
     cluster = util.lsf_vars_to_clusterspec(vars)
     self.assertEqual([
         config.MachineSpec('socket=hostA:15732', 'hostA', [0, 1], None),
         config.MachineSpec('socket=hostB:15732', 'hostB', [0], None)
     ], cluster.nodes)
Ejemplo n.º 2
0
 def test_gpufile_processing(self):
     fd, path = tempfile.mkstemp()
     f = os.fdopen(fd, 'w')
     f.write("node1-gpu2.domain-gpu0\n"
             "node1-gpu2.domain-gpu2\n"
             "node2-gpu4.domain-gpu0")
     f.close()
     random.seed(1234)
     cluster = util.gpufile_to_clusterspec(path)
     os.unlink(path)
     self.assertEqual([
         config.MachineSpec('socket=node1-gpu2.domain:%d' % PORT,
                            'node1-gpu2.domain', [0, 2], None),
         config.MachineSpec('socket=node2-gpu4.domain:%d' % PORT,
                            'node2-gpu4.domain', [0], None)
     ], cluster.nodes)
Ejemplo n.º 3
0
def _cluster_from_nodes_dict(nodes, iface):
    port = random.randint(8000, 16000)
    if not iface:
        iface = None

    cluster = []
    for node, gpus in sorted(nodes.items()):
        try:
            ipaddr = socket.gethostbyname(node)
        except socket.error:
            ipaddr = node
        cluster.append(config.MachineSpec('socket=%s:%s' % (ipaddr, port),
            node, gpus=list(gpus), iface=iface))

    class Cluster(object):
        def __init__(self, nodes):
            self.nodes = nodes

    return Cluster(cluster)