Commit 0ac6af16 authored by Alexander Pacha's avatar Alexander Pacha Committed by Francisco Massa

Using existing get_world_size to prevent AttributeError 'torch.distributed' has…

Using existing get_world_size to prevent AttributeError 'torch.distributed' has no attribute 'is_initialized'. (#511)
parent 75523a75
...@@ -8,7 +8,7 @@ import torch ...@@ -8,7 +8,7 @@ import torch
from tqdm import tqdm from tqdm import tqdm
from maskrcnn_benchmark.data.datasets.evaluation import evaluate from maskrcnn_benchmark.data.datasets.evaluation import evaluate
from ..utils.comm import is_main_process from ..utils.comm import is_main_process, get_world_size
from ..utils.comm import all_gather from ..utils.comm import all_gather
from ..utils.comm import synchronize from ..utils.comm import synchronize
...@@ -64,11 +64,7 @@ def inference( ...@@ -64,11 +64,7 @@ def inference(
): ):
# convert to a torch.device for efficiency # convert to a torch.device for efficiency
device = torch.device(device) device = torch.device(device)
num_devices = ( num_devices = get_world_size()
torch.distributed.get_world_size()
if torch.distributed.is_initialized()
else 1
)
logger = logging.getLogger("maskrcnn_benchmark.inference") logger = logging.getLogger("maskrcnn_benchmark.inference")
dataset = data_loader.dataset dataset = data_loader.dataset
logger.info("Start evaluation on {} dataset({} images).".format(dataset_name, len(dataset))) logger.info("Start evaluation on {} dataset({} images).".format(dataset_name, len(dataset)))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment