Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set default workers=0 for Windows #205

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading