If Gloo works fine then it means all the env vars and configs should be correct.

How can I upgrade NCCL version in torch.

That will require modify pytorch NCCL submodule and recompile. Like this https://github.com/pytorch/pytorch/pull/40622 5. You can pull this PR can compile from it, which should be using NCCL 2.7.3.
Another option is to set export USE_SYSTEM_NCCL=1, and then compile from source, then it should be using the 2.5 that you installed on the machine.