Skip to content

Commit

Permalink
set default workers=0 for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
BramVanroy committed Mar 2, 2024
1 parent fd3c2d9 commit 9dac863
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion comet/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import abc
import logging
import os
import sys
import warnings
from typing import Dict, List, Optional, Tuple, Union

Expand Down Expand Up @@ -592,9 +593,16 @@ def predict(
sort_ids = np.argsort([len(sample["ref"]) for sample in samples])
sampler = OrderedSampler(sort_ids)

# On Windows, only num_workers=0 is supported.
is_windows = os.name == "nt"
if num_workers is None:
# Guideline for workers that typically works well.
num_workers = 2 * gpus
num_workers = 0 if is_windows else 2 * gpus
elif is_windows and num_workers != 0:
logger.warning(
"Due to limits of multiprocessing on Windows, it is likely that setting num_workers > 0 will result"
" in scores of 0. It is therefore recommended to set num_workers=0 or leave it to None (default)."
)

self.eval()
dataloader = DataLoader(
Expand Down

0 comments on commit 9dac863

Please sign in to comment.