Avoid TensorPipe agent spamming logs when unable to guess IP address (#51784)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/51784
The TensorPipe agent mimics Gloo when trying to guess the most reasonable IP address to bind to. When that fails, it prints a warning to inform the user. It turns out, we were attempting to guess the address a lot of times (I counted at least 18: 1 for the UV transport, 1 for the IBV transport, 16 for the multiplexed UV channel) and thus they might all print that same identical warning message. That's noisy. Since the outcome of all these guesses will be the same (unless the system config changes underneath, which is unlikely) we can just do it once, print the warning (at most) once, cache the result and reuse it over and over.
Also, we used to have two identical but distinct ways of doing this, one provided by the UV transport and one by the IBV one. TensorPipe offers both methods because backends are modular and independent. However PyTorch always requires the UV one to be present, hence we can always rely on the UV helpers, and avoid using the IBV ones.
ghstack-source-id: 121121275
Test Plan: Look at the CircleCI logs, I think I saw this situation happening there.
Reviewed By: mrshenli
Differential Revision: D26275838
fbshipit-source-id: 8a2ffc40d80388bdca32dbcfed16f28a0a6177a3