Update train_ms.py. Auto choose gloo backend while using Windows platform. (#134)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
# flake8: noqa: E402
|
# flake8: noqa: E402
|
||||||
|
|
||||||
|
import platform
|
||||||
import os
|
import os
|
||||||
import torch
|
import torch
|
||||||
from torch.nn import functional as F
|
from torch.nn import functional as F
|
||||||
@@ -53,8 +54,11 @@ def run():
|
|||||||
os.environ[env_name] = str(env_value)
|
os.environ[env_name] = str(env_value)
|
||||||
|
|
||||||
# 多卡训练设置
|
# 多卡训练设置
|
||||||
|
backend = "nccl"
|
||||||
|
if platform.system() == "Windows":
|
||||||
|
backend = "gloo"
|
||||||
dist.init_process_group(
|
dist.init_process_group(
|
||||||
backend="nccl",
|
backend=backend,
|
||||||
init_method="env://", # If Windows,switch to gloo backend.
|
init_method="env://", # If Windows,switch to gloo backend.
|
||||||
) # Use torchrun instead of mp.spawn
|
) # Use torchrun instead of mp.spawn
|
||||||
rank = dist.get_rank()
|
rank = dist.get_rank()
|
||||||
|
|||||||
Reference in New Issue
Block a user