Java Code Examples for org.nd4j.parameterserver.distributed.conf.VoidConfiguration#setUnicastControllerPort()

The following examples show how to use org.nd4j.parameterserver.distributed.conf.VoidConfiguration#setUnicastControllerPort() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VoidParameterServerTest.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 30000L)
public void testNodeRole1() throws Exception {
    final VoidConfiguration conf = VoidConfiguration.builder().multicastPort(45678)
                    .numberOfShards(10).multicastNetwork("224.0.1.1").shardAddresses(localIPs).ttl(4).build();
    conf.setUnicastControllerPort(34567);

    VoidParameterServer node = new VoidParameterServer();
    node.init(conf, transport, new SkipGramTrainer());

    assertEquals(NodeRole.SHARD, node.getNodeRole());
    node.shutdown();
}
 
Example 2
Source File: VoidParameterServerTest.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 30000L)
public void testNodeRole2() throws Exception {
    final VoidConfiguration conf = VoidConfiguration.builder().multicastPort(45678)
                    .numberOfShards(10).shardAddresses(badIPs).backupAddresses(localIPs)
                    .multicastNetwork("224.0.1.1").ttl(4).build();
    conf.setUnicastControllerPort(34567);

    VoidParameterServer node = new VoidParameterServer();
    node.init(conf, transport, new SkipGramTrainer());

    assertEquals(NodeRole.BACKUP, node.getNodeRole());
    node.shutdown();
}
 
Example 3
Source File: VoidParameterServerTest.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 30000L)
public void testNodeRole3() throws Exception {
    final VoidConfiguration conf = VoidConfiguration.builder().multicastPort(45678)
                    .numberOfShards(10).shardAddresses(badIPs).backupAddresses(badIPs).multicastNetwork("224.0.1.1")
                    .ttl(4).build();
    conf.setUnicastControllerPort(34567);

    VoidParameterServer node = new VoidParameterServer();
    node.init(conf, transport, new SkipGramTrainer());

    assertEquals(NodeRole.CLIENT, node.getNodeRole());
    node.shutdown();
}
 
Example 4
Source File: VoidParameterServerTest.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 60000L)
public void testNodeInitialization1() throws Exception {
    final AtomicInteger failCnt = new AtomicInteger(0);
    final AtomicInteger passCnt = new AtomicInteger(0);

    final VoidConfiguration conf = VoidConfiguration.builder().multicastPort(45678)
                    .numberOfShards(10).shardAddresses(localIPs).multicastNetwork("224.0.1.1").ttl(4).build();
    conf.setUnicastControllerPort(34567);

    Thread[] threads = new Thread[10];
    for (int t = 0; t < threads.length; t++) {
        threads[t] = new Thread(new Runnable() {
            @Override
            public void run() {
                VoidParameterServer node = new VoidParameterServer();
                node.init(conf, transport, new SkipGramTrainer());

                if (node.getNodeRole() != NodeRole.SHARD)
                    failCnt.incrementAndGet();

                passCnt.incrementAndGet();

                node.shutdown();
            }
        });

        threads[t].start();
    }


    for (int t = 0; t < threads.length; t++) {
        threads[t].join();
    }

    assertEquals(0, failCnt.get());
    assertEquals(threads.length, passCnt.get());
}
 
Example 5
Source File: VoidParameterServerStressTest.java    From deeplearning4j with Apache License 2.0 4 votes vote down vote up
/**
 * This test checks for single Shard scenario, when Shard is also a Client
 *
 * @throws Exception
 */
@Test(timeout = 60000L)
public void testPerformanceUnicast3() throws Exception {
    VoidConfiguration voidConfiguration = VoidConfiguration.builder().numberOfShards(1)
                    .shardAddresses(Arrays.asList("127.0.0.1:49823")).build();
    voidConfiguration.setUnicastControllerPort(49823);

    Transport transport = new RoutedTransport();
    transport.setIpAndPort("127.0.0.1", Integer.valueOf("49823"));

    VoidParameterServer parameterServer = new VoidParameterServer(NodeRole.SHARD);
    parameterServer.setShardIndex((short) 0);
    parameterServer.init(voidConfiguration, transport, new CbowTrainer());

    parameterServer.initializeSeqVec(100, NUM_WORDS, 123L, 100, true, false);

    final List<Long> times = new ArrayList<>();

    log.info("Starting loop...");
    for (int i = 0; i < 200; i++) {
        Frame<CbowRequestMessage> frame = new Frame<>(BasicSequenceProvider.getInstance().getNextValue());
        for (int f = 0; f < 128; f++) {
            frame.stackMessage(getCRM());
        }
        long time1 = System.nanoTime();
        parameterServer.execDistributed(frame);
        long time2 = System.nanoTime();

        times.add(time2 - time1);

        if (i % 50 == 0)
            log.info("{} frames passed...", i);
    }


    Collections.sort(times);

    log.info("p50: {} us", times.get(times.size() / 2) / 1000);

    parameterServer.shutdown();
}