Skip to content

Commit

Permalink
W&B: fix DDP with wandb disabled (#5163)
Browse files Browse the repository at this point in the history
* fix dpp with wandb disabled

* PyCharm reformat

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
  • Loading branch information
AyushExel and glenn-jocher committed Oct 13, 2021
1 parent a346926 commit d0bfeb3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
7 changes: 7 additions & 0 deletions utils/loggers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
Logging utils
"""

import os
import warnings
from threading import Thread

import pkg_resources as pkg
import torch
from torch.utils.tensorboard import SummaryWriter

Expand All @@ -15,11 +17,16 @@
from utils.torch_utils import de_parallel

LOGGERS = ('csv', 'tb', 'wandb') # text-file, TensorBoard, Weights & Biases
RANK = int(os.getenv('RANK', -1))

try:
import wandb

assert hasattr(wandb, '__version__') # verify package import not local dir
if pkg.parse_version(wandb.__version__) >= pkg.parse_version('0.12.2') and RANK in [0, -1]:
wandb_login_success = wandb.login(timeout=30)
if not wandb_login_success:
wandb = None
except (ImportError, AssertionError):
wandb = None

Expand Down
10 changes: 0 additions & 10 deletions utils/loggers/wandb/wandb_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@
from utils.general import check_dataset, check_file

RANK = int(os.getenv('RANK', -1))

try:
import wandb

assert hasattr(wandb, '__version__') # verify package import not local dir
if pkg.parse_version(wandb.__version__) >= pkg.parse_version('0.12.2') and RANK in [0, -1]:
wandb.login(timeout=30)
except (ImportError, AssertionError):
wandb = None

WANDB_ARTIFACT_PREFIX = 'wandb-artifact://'


Expand Down

0 comments on commit d0bfeb3

Please sign in to comment.