Does torch.distributed support the ipv6 address?

username: khalil
cooked: <p>Hi All,<br>
Now I import the torch.distributed package to train my model in some nodes. And I want to use the CPU to train it so I use gloo as the backend.</p>
<p>When I use this package to do distributed training, I should set some Common environment variables like <strong>GLOO_SOCKET_IFNAME</strong> and <strong>MASTER_ADDR</strong>.I use the ifconfig command to print the interface, it just like this.<br>
<img src="https://discuss.pytorch.org/uploads/default/original/3X/4/9/490eedb93e6a52261d358cafaa19eb50503b9168.png" alt="image" data-base62-sha1="aqiQ3WYEa0zfNqOYRVAHKfwtlws" width="630" height="432"></p>
<p>I want to know how to set these environment variables to running  python -m torch.distributed.launch correctly.Thanks!!!</p>

username: mrshenli
cooked: <p>I haven’t tried myself, but I think it should work as the code does seem to handle ipv6:</p>
<aside class="onebox githubblob">
  <header class="source">
      <a href="https://github.com/pytorch/pytorch/blob/db81e13d6b061fe7b219a6ef4d05e8b4223dd0c3/torch/lib/c10d/Utils.cpp#L205" target="_blank" rel="nofollow noopener">github.com</a>
  </header>
  <article class="onebox-body">
    <h4><a href="https://github.com/pytorch/pytorch/blob/db81e13d6b061fe7b219a6ef4d05e8b4223dd0c3/torch/lib/c10d/Utils.cpp#L205" target="_blank" rel="nofollow noopener">pytorch/pytorch/blob/db81e13d6b061fe7b219a6ef4d05e8b4223dd0c3/torch/lib/c10d/Utils.cpp#L205</a></h4>
<pre class="onebox"><code class="lang-cpp"><ol class="start lines" start="195" style="counter-reset: li-counter 194 ;">
<li>}</li>
<li>
</li><li>int connect(</li>
<li>    const std::string&amp; address,</li>
<li>    PortType port,</li>
<li>    bool wait,</li>
<li>    const std::chrono::milliseconds&amp; timeout) {</li>
<li>  struct ::addrinfo hints, *res = NULL;</li>
<li>  std::memset(&amp;hints, 0x00, sizeof(hints));</li>
<li>  hints.ai_flags = AI_NUMERICSERV; // specifies that port (service) is numeric</li>
<li class="selected">  hints.ai_family = AF_UNSPEC; // either IPv4 or IPv6</li>
<li>  hints.ai_socktype = SOCK_STREAM; // TCP</li>
<li>
</li><li>  // `getaddrinfo` will sort addresses according to RFC 3484 and can be tweeked</li>
<li>  // by editing `/etc/gai.conf`. so there is no need to manual sorting</li>
<li>  // or protcol preference.</li>
<li>  int err =</li>
<li>      ::getaddrinfo(address.data(), std::to_string(port).data(), &amp;hints, &amp;res);</li>
<li>  if (err != 0 || !res) {</li>
<li>    throw std::invalid_argument(</li>
<li>        "host not found: " + std::string(gai_strerror(err)));</li>
</ol></code></pre>


  </article>
  <div class="onebox-metadata">
    
    
  </div>
  <div style="clear: both"></div>
</aside>

<p>Can you try setting <code>GLOO_SOCKET_IFNAME</code> to <code>eth0</code>, <code>MASTER_ADDR</code> to its inet6 string, and <code>MASTER_PORT</code> to, say, 23456?</p>

username: khalil
cooked: <p>Thank you, mrshenli. I tried setting CLOO_SOCKET_IFNAME to eth0 and MASTER_ADDR to inet6 string, it returned a connection error(Timeout). Then I found gn0 might be an Infiniband Interface, so I set CLOO_SOCKET_IFNAME to gn0 and MASTER_ADDR to ipv4 address.</p>
<p>From the code, I think the MASTER_ADDR can be set to ipv6, thanks for your help!</p>