Error: address family mismatch

111282: <p>hi, I try to run the <a href="https://pytorch.org/tutorials/intermediate/rpc_param_server_tutorial.html" rel="noopener nofollow ugc">tutorial example</a> in two machines.</p>
<p>One is my local mac(IP: 192.168.1.57), the other is a docker container(ubuntu) in a linux server(server IP: 192.168.60.67). I use a vpn to visit the server from my mac.</p>
<p>When creating the container, I mapped its port 60000(available) to the same port of the server. I want to first create a remote parameter server process(rank0) on the container, and a local worker process(rank1)  on my mac. Then the worker will send some objects to the server, through the special address and port(“192.168.60.67:60000”).</p>
<p>The code:</p>
<pre data-code-wrap="python"><code class="lang-python">#!/usr/bin/env python
# coding:utf-8

import argparse
import os
import time
from threading import Lock

import torch
import torch.distributed.autograd as dist_autograd
import torch.distributed.rpc as rpc
import torch.multiprocessing as mp
import torch.nn as nn
import torch.nn.functional as F
from torch import optim
from torch.distributed.optim import DistributedOptimizer
from torch.distributed.rpc import BackendType
from torchvision import datasets, transforms

# --------- MNIST Network to train, from pytorch/examples -----

class Net(nn.Module):
    def __init__(self, num_gpus=0):
        super(Net, self).__init__()
        print(f"Using {num_gpus} GPUs to train")
        self.num_gpus = num_gpus
        device = torch.device(
            "cuda:0" if torch.cuda.is_available() and self.num_gpus &gt; 0 else "cpu")
        print(f"Putting first 2 convs on {str(device)}")
        # Put conv layers on the first cuda device, or CPU if no cuda device
        self.conv1 = nn.Conv2d(1, 32, 3, 1).to(device)
        self.conv2 = nn.Conv2d(32, 64, 3, 1).to(device)
        # Put rest of the network on the 2nd cuda device, if there is one
        if "cuda" in str(device) and num_gpus &gt; 1:
            device = torch.device("cuda:1")

        print(f"Putting rest of layers on {str(device)}")
        self.dropout1 = nn.Dropout2d(0.25).to(device)
        self.dropout2 = nn.Dropout2d(0.5).to(device)
        self.fc1 = nn.Linear(9216, 128).to(device)
        self.fc2 = nn.Linear(128, 10).to(device)

    def forward(self, x):
        x = self.conv1(x)
        x = F.relu(x)
        x = self.conv2(x)
        x = F.max_pool2d(x, 2)

        x = self.dropout1(x)
        x = torch.flatten(x, 1)
        # Move tensor to next device if necessary
        next_device = next(self.fc1.parameters()).device
        x = x.to(next_device)

        x = self.fc1(x)
        x = F.relu(x)
        x = self.dropout2(x)
        x = self.fc2(x)
        output = F.log_softmax(x, dim=1)
        return output


# --------- Helper Methods --------------------

def call_method(method, rref, *args, **kwargs):
    return method(rref.local_value(), *args, **kwargs)

def remote_method(method, rref, *args, **kwargs):
    args = [method, rref] + list(args)
    return rpc.rpc_sync(rref.owner(), call_method, args=args, kwargs=kwargs)


# --------- Parameter Server --------------------
class ParameterServer(nn.Module):
    def __init__(self, num_gpus=0):
        super().__init__()
        model = Net(num_gpus=num_gpus)
        self.model = model
        self.input_device = torch.device(
            "cuda:0" if torch.cuda.is_available() and num_gpus &gt; 0 else "cpu")

    def forward(self, inp):
        inp = inp.to(self.input_device)
        out = self.model(inp)
        # This output is forwarded over RPC, which as of 1.5.0 only accepts CPU tensors.
        # Tensors must be moved in and out of GPU memory due to this.
        out = out.to("cpu")
        return out

    # Use dist autograd to retrieve gradients accumulated for this model.
    # Primarily used for verification.
    def get_dist_gradients(self, cid):
        grads = dist_autograd.get_gradients(cid)
        # This output is forwarded over RPC, which as of 1.5.0 only accepts CPU tensors.
        # Tensors must be moved in and out of GPU memory due to this.
        cpu_grads = {}
        for k, v in grads.items():
            k_cpu, v_cpu = k.to("cpu"), v.to("cpu")
            cpu_grads[k_cpu] = v_cpu
        return cpu_grads

    # Wrap local parameters in a RRef. Needed for building the
    # DistributedOptimizer which optimizes paramters remotely.
    def get_param_rrefs(self):
        param_rrefs = [rpc.RRef(param) for param in self.model.parameters()]
        return param_rrefs


# The global parameter server instance.
param_server = None
# A lock to ensure we only have one parameter server.
global_lock = Lock()


def get_parameter_server(num_gpus=0):
    """
    Returns a singleton parameter server to all trainer processes
    """
    global param_server
    # Ensure that we get only one handle to the ParameterServer.
    with global_lock:
        if not param_server:
            # construct it once
            param_server = ParameterServer(num_gpus=num_gpus)
        return param_server

def run_parameter_server(rank, world_size):
    print("PS master initializing RPC")
    rpc.init_rpc(name="parameter_server", rank=rank, world_size=world_size)
    print("RPC initialized! Running parameter server...")
    rpc.shutdown()
    print("RPC shutdown on parameter server.")


# --------- Trainers --------------------

class TrainerNet(nn.Module):
    def __init__(self, num_gpus=0):
        super().__init__()
        self.num_gpus = num_gpus
        self.param_server_rref = rpc.remote(
            "parameter_server", get_parameter_server, args=(num_gpus,))

    def get_global_param_rrefs(self):
        remote_params = remote_method(
            ParameterServer.get_param_rrefs,
            self.param_server_rref)
        return remote_params

    def forward(self, x):
        model_output = remote_method(
            ParameterServer.forward, self.param_server_rref, x)
        return model_output


def run_training_loop(rank, num_gpus, train_loader, test_loader):
    # Runs the typical nueral network forward + backward + optimizer step, but
    # in a distributed fashion.
    net = TrainerNet(num_gpus=num_gpus)
    # Build DistributedOptimizer.
    param_rrefs = net.get_global_param_rrefs()
    opt = DistributedOptimizer(optim.SGD, param_rrefs, lr=0.03)

    for i, (data, target) in enumerate(train_loader):
        with dist_autograd.context() as cid:
            model_output = net(data)
            target = target.to(model_output.device)
            loss = F.nll_loss(model_output, target)
            if i % 5 == 0:
                print(f"Rank {rank} training batch {i} loss {loss.item()}")
            dist_autograd.backward(cid, [loss])
            # Ensure that dist autograd ran successfully and gradients were
            # returned.
            assert remote_method(
                ParameterServer.get_dist_gradients,
                net.param_server_rref,
                cid) != {}
            opt.step(cid)

    print("Training complete!")
    print("Getting accuracy....")
    get_accuracy(test_loader, net)


def get_accuracy(test_loader, model):
    model.eval()
    correct_sum = 0
    # Use GPU to evaluate if possible
    device = torch.device("cuda:0" if model.num_gpus &gt; 0
                                      and torch.cuda.is_available() else "cpu")
    with torch.no_grad():
        for i, (data, target) in enumerate(test_loader):
            out = model(data, -1)
            pred = out.argmax(dim=1, keepdim=True)
            pred, target = pred.to(device), target.to(device)
            correct = pred.eq(target.view_as(pred)).sum().item()
            correct_sum += correct

    print(f"Accuracy {correct_sum / len(test_loader.dataset)}")


# Main loop for trainers.
def run_worker(rank, world_size, num_gpus, train_loader, test_loader):
    print(f"Worker rank {rank} initializing RPC")
    options = rpc.ProcessGroupRpcBackendOptions(
        num_send_recv_threads=8,
        rpc_timeout=0,
        init_method="tcp://192.168.60.67:60000"
    )
    rpc.init_rpc(
        backend=BackendType.PROCESS_GROUP,
        # backend=rpc.BackendType.TENSORPIPE,
        name=f"trainer_{rank}",
        rank=rank,
        world_size=world_size,
        # rpc_backend_options=options,
    )

    print(f"Worker {rank} done initializing RPC")

    run_training_loop(rank, num_gpus, train_loader, test_loader)
    rpc.shutdown()


if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description="Parameter-Server RPC based training")
    parser.add_argument(
        "--world_size",
        type=int,
        default=2,
        help="""Total number of participating processes. Should be the sum of
        master node and all training nodes.""")
    parser.add_argument(
        "--rank",
        type=int,
        default=0,
        help="Global rank of this process. Pass in 0 for master.")
    parser.add_argument(
        "--num_gpus",
        type=int,
        default=2,
        help="""Number of GPUs to use for training, Currently supports between 0
         and 2 GPUs. Note that this argument will be passed to the parameter servers.""")
    parser.add_argument(
        "--master_addr",
        type=str,
        default="localhost",
        help="""Address of master, will default to localhost if not provided.
        Master must be able to accept network traffic on the address + port.""")
    parser.add_argument(
        "--master_port",
        type=str,
        default="29500",
        help="""Port that master is listening on, will default to 29500 if not
        provided. Master must be able to accept network traffic on the host and port.""")

    args = parser.parse_args()
    assert args.rank is not None, "must provide rank argument."
    assert args.num_gpus &lt;= 3, f"Only 0-2 GPUs currently supported (got {args.num_gpus})."
    os.environ['MASTER_ADDR'] = args.master_addr
    os.environ["MASTER_PORT"] = args.master_port

    processes = []
    world_size = args.world_size
    if args.rank == 0:
        p = mp.Process(target=run_parameter_server, args=(0, world_size))
        p.start()
        processes.append(p)
    else:
        # Get data to train on
        train_loader = torch.utils.data.DataLoader(
            datasets.MNIST('./data', train=True, download=True,
                           transform=transforms.Compose([
                               transforms.ToTensor(),
                               transforms.Normalize((0.1307,), (0.3081,))
                           ])),
            batch_size=32, shuffle=True, )
        test_loader = torch.utils.data.DataLoader(
            datasets.MNIST(
                './data',
                train=False,
                transform=transforms.Compose([
                    transforms.ToTensor(),
                    transforms.Normalize((0.1307,), (0.3081,))
                ])),
            batch_size=32,
            shuffle=True,
        )
        # start training worker on this node
        p = mp.Process(
            target=run_worker,
            args=(
                args.rank,
                world_size, args.num_gpus,
                train_loader,
                test_loader))
        p.start()
        processes.append(p)

    for p in processes:
        p.join()
</code></pre>
<p>First I run the above code(tutorial.py) in the remote container to create a server process :</p>
<pre><code class="lang-auto">python tutorial.py --rank=0 --num_gpus=2 --master_addr="localhost" --master_port="60000" --world_size=2
</code></pre>
<p>Second I run the same code in my mac to create the worker process, with some different args:</p>
<pre><code class="lang-auto">python tutorial.py --rank=1 --num_gpus=2 --master_addr="192.168.60.67" --master_port="60000" --world_size=2 
</code></pre>
<p>One error occurs in both nodes.<br>
In the container:<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/d/a/da0b90c6af3729ae05ab855f0a4ce762fe699393.png" data-download-href="https://discuss.pytorch.org/uploads/default/da0b90c6af3729ae05ab855f0a4ce762fe699393" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/d/a/da0b90c6af3729ae05ab855f0a4ce762fe699393.png" alt="image" data-base62-sha1="v6URN2eSgunvdBXx7ioQwY4Ihc7" width="689" height="337" data-dominant-color="23272D"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1344×658 57.7 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>In my mac:<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/e/d/edee3705b762cc4b1e2019bb3b12ec30210b1bbd.png" data-download-href="https://discuss.pytorch.org/uploads/default/edee3705b762cc4b1e2019bb3b12ec30210b1bbd" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/e/d/edee3705b762cc4b1e2019bb3b12ec30210b1bbd_2_690x183.png" alt="image" data-base62-sha1="xWPx5hv1FxpugmbrudiZhJAYn7L" width="690" height="183" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/e/d/edee3705b762cc4b1e2019bb3b12ec30210b1bbd_2_690x183.png, https://discuss.pytorch.org/uploads/default/optimized/3X/e/d/edee3705b762cc4b1e2019bb3b12ec30210b1bbd_2_1035x274.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/e/d/edee3705b762cc4b1e2019bb3b12ec30210b1bbd_2_1380x366.png 2x" data-dominant-color="EFEFF7"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1536×408 69.5 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>I change the master_addr in first comand line to “127.0.0.1” or “192.168.60.67”, but it’s the same error.</p>
<p>Also I set the special environment variables, but it does not work:</p>
<pre><code class="lang-auto"># in container
export GLOO_SOCKET_IFNAME=eth0,lo
export TP_SOCKET_IFNAME=eth0,lo
# in mac
export GLOO_SOCKET_IFNAME=en0,lo
export TP_SOCKET_IFNAME=en0,lo

</code></pre>
<p>Any advice would be appreciated, thanks.</p>

111282: <p>My torch version is 1.8</p>

111282: <p>I think the error results from different networks of the two nodes(one 192.168.1.57 and the other 192.168.60.67). So I use two other machines with IP addresses 192.168.206.100(as a worker) and 192.168.206.101(as a params server) respectively. Similarly I use a docker container in each machine.</p>
<p>It successfully solves the above mismatch error, but a new error occurs on the worker node: “… connection to [172.17.0.10]:5807 is refused”. “172.17.0.10” is the IP address of the container and “5807” is a random port. Notice that the master address I set is 192.168.206.101 and the master port 60000 as above.<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/9/4/94a3f158242bb786a3874ef45da4c71d0ca55942.png" data-download-href="https://discuss.pytorch.org/uploads/default/94a3f158242bb786a3874ef45da4c71d0ca55942" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/9/4/94a3f158242bb786a3874ef45da4c71d0ca55942_2_690x200.png" alt="image" data-base62-sha1="lcVUverBT0NeLAwQh3GC80kNfX4" width="690" height="200" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/9/4/94a3f158242bb786a3874ef45da4c71d0ca55942_2_690x200.png, https://discuss.pytorch.org/uploads/default/optimized/3X/9/4/94a3f158242bb786a3874ef45da4c71d0ca55942_2_1035x300.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/9/4/94a3f158242bb786a3874ef45da4c71d0ca55942_2_1380x400.png 2x" data-dominant-color="191414"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">2752×798 371 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>In the <a href="https://discuss.pytorch.org/t/connect-127-0-1-1-a-port-connection-refused/100802">disscussion</a>,  <a class="mention" href="/u/lcw">@lcw</a> says some “real” connections exist. The random port is created by one of these connections.<br>
###########<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/2/2/227e5bef8904431f9ead0a8e97fe8992175a6df9.png" data-download-href="https://discuss.pytorch.org/uploads/default/227e5bef8904431f9ead0a8e97fe8992175a6df9" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/2/2/227e5bef8904431f9ead0a8e97fe8992175a6df9_2_690x226.png" alt="image" data-base62-sha1="4V8XlmgkBFaEpNyHVPojQu7RCwp" width="690" height="226" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/2/2/227e5bef8904431f9ead0a8e97fe8992175a6df9_2_690x226.png, https://discuss.pytorch.org/uploads/default/optimized/3X/2/2/227e5bef8904431f9ead0a8e97fe8992175a6df9_2_1035x339.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/2/2/227e5bef8904431f9ead0a8e97fe8992175a6df9.png 2x" data-dominant-color="E2DCDB"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1378×452 98 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
##########</p>
<p>As only the port 60000 of the container is mapped to the same port of the host(server), a random port(such as 5807) may not be accessed. So the connection to such a random port is refused.</p>
<p>Can I still use a docker container on each machine?</p>
<p>thanks.</p>

lcw: <p>A couple of things here. All the error messages so far come from Gloo, whereas I mostly know TensorPipe, hence I’m not 100% sure about what I’m saying.</p>
<p>First, the “address family mismatch” error in my opinion comes from the fact that you specified <code>localhost</code> and <code>192.168.60.67</code> as the master address for your two nodes. Even though these two addresses resolve to the same physical machine, they correspond to different interfaces on that machine, hence the mismatch. In particular it’s possible that <code>localhost</code> resolved to the <code>::1</code> IPv6 address, and this caused Gloo to detect a mismatch. You should specify <code>192.168.60.67</code> as the master address on both nodes.</p>
<p>Second, your goal seems to be to have the server listen on port 60000 <em>only</em> and have all connections go through there. This, AFAIK, is <em>not</em> possible with Gloo or TensorPipe today. You are certainly allowed to specify the master port, and it will be honored, but that is only used for rendezvous, i.e., for processes to “discover” each other. In practice, each process will start listening on a new random arbitrary port (and it will communicate this port to the other processes using that rendezvous). And I believe there is <em>no way</em> to influence how that arbitrary port is selected. Hence you probably will need to map the whole range of ports, or find some other way to put the two machines on the same network, or something of that sort.</p>
<p>Finally, you seemed to be trying to connect a Linux machine to an OSX machine. While this might in principle be possible, and perhaps it might even work, I don’t think we ever explicitly supported this scenario. I wouldn’t be surprised if somewhere in the code we introduced the assumption that all endpoints are running on the same platform and, possibly, that they are running the same exact binary version of PyTorch.</p>

111282: <p><a class="mention" href="/u/lcw">@lcw</a> thanks.</p>
<p>Now I use two machines in the same network with addresses 192.168.206.100(called office0) and 192.168.206.101(called office1) respectively. Each can ping the other successfully.</p>
<p>I set the master_addr=192.168.206.100 and master_port=5234(random), then launch the master process on office0 and worker process on office1. the commands are as follows:</p>
<pre><code class="lang-auto"># launch on office0(192.168.206.100, as master)
python tutorial.py --rank=0 --num_gpus=0 --master_addr="192.168.206.100" --master_port="5024" --world_size=2

# launch on office1(192.168.206.101, as worker)
python tutorial.py --rank=1 --num_gpus=0 --master_addr="192.168.206.100" --master_port="5024" --world_size=2
</code></pre>
<p>I find the master process and worker process are created after the two commands. But the problem is both processes appear to be blocked until one times out.</p>
<p>on office0(192.168.206.100)<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/d/7/d74830335ad4c94fa412859473fee4f054a3f24f.png" data-download-href="https://discuss.pytorch.org/uploads/default/d74830335ad4c94fa412859473fee4f054a3f24f" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/d/7/d74830335ad4c94fa412859473fee4f054a3f24f_2_690x79.png" alt="image" data-base62-sha1="uItjLAkl90TeJdKp2YRW5E1qPcr" width="690" height="79" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/d/7/d74830335ad4c94fa412859473fee4f054a3f24f_2_690x79.png, https://discuss.pytorch.org/uploads/default/optimized/3X/d/7/d74830335ad4c94fa412859473fee4f054a3f24f_2_1035x118.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/d/7/d74830335ad4c94fa412859473fee4f054a3f24f_2_1380x158.png 2x" data-dominant-color="26262B"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1388×160 24.3 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>on office1(192.168.206.101)<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/3/f/3fa123a068f0f2564b9dcf56b57d6468ebfcfca5.png" data-download-href="https://discuss.pytorch.org/uploads/default/3fa123a068f0f2564b9dcf56b57d6468ebfcfca5" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/3/f/3fa123a068f0f2564b9dcf56b57d6468ebfcfca5_2_690x77.png" alt="image" data-base62-sha1="94TjOXRS8POE6MzhMh0qhndfEyh" width="690" height="77" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/3/f/3fa123a068f0f2564b9dcf56b57d6468ebfcfca5_2_690x77.png, https://discuss.pytorch.org/uploads/default/optimized/3X/3/f/3fa123a068f0f2564b9dcf56b57d6468ebfcfca5_2_1035x115.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/3/f/3fa123a068f0f2564b9dcf56b57d6468ebfcfca5.png 2x" data-dominant-color="24252A"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1368×154 23.6 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>each “@” indicates one or two minutes.</p>
<p>I don’t have a clue.</p>

lcw: <p>If you terminate the processes (e.g., Ctrl+C) you should be able to see a backtrace telling you where they are stuck. Is it at the <code>init_rpc</code> function?</p>
<p>If so, <a class="mention" href="/u/mrshenli">@mrshenli</a> do you know if we have a way to get more verbose logging information from the TCPStore to see what’s going on?</p>
<p>There’s one thing you could try in the meantime. Even if two machines can ping each other, it doesn’t mean that they can connect to all the ports. You could check this by running <code>nc -l 192.168.206.100 5024</code> on the server and then <code>nc 192.168.206.100 5024</code> (without <code>-l</code>!) on the client, and type something (+ a newline) on the client’s console and see if it appears on the server’s one. The <code>nc</code> is netcat which on some distributions is called differently, you should check yours.</p>

111282: <p>yes, they are stuck at the init_rpc function. The function creates a process(found using “top” or “ps -ef” command), but can’t proceed further and can’t print the “Worker {rank} done initializing RPC”.<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/b/b/bbfa9a88c13841c87fd2ef3ed05099d2f609a029.png" data-download-href="https://discuss.pytorch.org/uploads/default/bbfa9a88c13841c87fd2ef3ed05099d2f609a029" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/b/b/bbfa9a88c13841c87fd2ef3ed05099d2f609a029_2_690x389.png" alt="image" data-base62-sha1="qOWczCM1QCyTmbogjfNU3s2APtn" width="690" height="389" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/b/b/bbfa9a88c13841c87fd2ef3ed05099d2f609a029_2_690x389.png, https://discuss.pytorch.org/uploads/default/original/3X/b/b/bbfa9a88c13841c87fd2ef3ed05099d2f609a029.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/b/b/bbfa9a88c13841c87fd2ef3ed05099d2f609a029.png 2x" data-dominant-color="F7F6F4"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">720×406 32.1 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>With Ctrl+C, the backtrace is as follows(both master and worker):<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/6/6/66ea7ced7ad6cc04e126fbc4fddeb2e7fd23b779.png" data-download-href="https://discuss.pytorch.org/uploads/default/66ea7ced7ad6cc04e126fbc4fddeb2e7fd23b779" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/6/6/66ea7ced7ad6cc04e126fbc4fddeb2e7fd23b779_2_690x362.png" alt="image" data-base62-sha1="eGr5AKB9DC93o0MMgVmTS9qf4i5" width="690" height="362" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/6/6/66ea7ced7ad6cc04e126fbc4fddeb2e7fd23b779_2_690x362.png, https://discuss.pytorch.org/uploads/default/optimized/3X/6/6/66ea7ced7ad6cc04e126fbc4fddeb2e7fd23b779_2_1035x543.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/6/6/66ea7ced7ad6cc04e126fbc4fddeb2e7fd23b779.png 2x" data-dominant-color="232429"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1352×710 93.9 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

111282: <p>I try to set “master_add=192.168.206.101” and “master_port=5024”, so the office1(192.168.206.101) will be the master and office0(192.168.206.100) the worker, which is the opposite of what I do above.</p>
<p>No stuck, but an error occurs. It says the master can’t route to a random port on the worker. The worker(office0) seems to have a firewall.<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/d/6/d61f82c98f737fe112e09d9b5db65aa79d01f960.png" data-download-href="https://discuss.pytorch.org/uploads/default/d61f82c98f737fe112e09d9b5db65aa79d01f960" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/d/6/d61f82c98f737fe112e09d9b5db65aa79d01f960_2_690x210.png" alt="image" data-base62-sha1="uydGO3LbqjNpJMMT8H3sXcVrn0c" width="690" height="210" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/d/6/d61f82c98f737fe112e09d9b5db65aa79d01f960_2_690x210.png, https://discuss.pytorch.org/uploads/default/optimized/3X/d/6/d61f82c98f737fe112e09d9b5db65aa79d01f960_2_1035x315.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/d/6/d61f82c98f737fe112e09d9b5db65aa79d01f960.png 2x" data-dominant-color="2B2C30"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1376×420 83.8 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

lcw: <p>Please try the <code>netcat</code> experiment I suggested. If that fails it means the issue is not in PyTorch but in your network setup, and you will have to solve it on your side (or with your system administrator if you have one).</p>

111282: <p>office0(client)-&gt;office1(server) is successful, but not the other way around.<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/e/2/e278e6359fca1a614d0a9fe95326fbf845c07b11.png" data-download-href="https://discuss.pytorch.org/uploads/default/e278e6359fca1a614d0a9fe95326fbf845c07b11" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/e/2/e278e6359fca1a614d0a9fe95326fbf845c07b11_2_690x103.png" alt="image" data-base62-sha1="wjsVTssXBiCpUAKgyWEU3CqmELv" width="690" height="103" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/e/2/e278e6359fca1a614d0a9fe95326fbf845c07b11_2_690x103.png, https://discuss.pytorch.org/uploads/default/optimized/3X/e/2/e278e6359fca1a614d0a9fe95326fbf845c07b11_2_1035x154.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/e/2/e278e6359fca1a614d0a9fe95326fbf845c07b11.png 2x" data-dominant-color="1A1E24"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1080×162 10.4 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/2/7/2747fddb98acc865314a658519826cd6ddb0a145.png" data-download-href="https://discuss.pytorch.org/uploads/default/2747fddb98acc865314a658519826cd6ddb0a145" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/2/7/2747fddb98acc865314a658519826cd6ddb0a145_2_690x95.png" alt="image" data-base62-sha1="5BuRufpVfakmyn39KHbqaIHk2xL" width="690" height="95" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/2/7/2747fddb98acc865314a658519826cd6ddb0a145_2_690x95.png, https://discuss.pytorch.org/uploads/default/original/3X/2/7/2747fddb98acc865314a658519826cd6ddb0a145.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/2/7/2747fddb98acc865314a658519826cd6ddb0a145.png 2x" data-dominant-color="1B1F25"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1028×142 10.8 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>So the office0 may have a firewall. I will ask my administrator.</p>
<p>thanks.</p>

lcw: <p>And you could also try that with a port other than 5024, to “simulate” a randomly-chosen port. For example, in the screenshot you posted above, port 34204 was being used.</p>