forked from facebookresearch/pycls
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minor cleanup after io migration to PathManager (facebookresearch#130)
Summary: best to view this commit using a diff from ca89a79 from 11/20/20 this diff looks big on its own, but it's MINIMAL versus ca89a79 this diff undos some of the orthogonal changes in previous few diffs -no longer using global path manager (which was deprecated) -cfg.merge_from_file replaced by load_cfg (old load_cfg unused) -correct / minimal requirement in requirements.txt -setup_env() moved back into trainer.py (should not be used elsewhere) -removed orthogonal changes to cifar10.py introduced in a prev commits Pull Request resolved: facebookresearch#130 Reviewed By: theschnitz Differential Revision: D27128859 Pulled By: pdollar fbshipit-source-id: 1029adca3b1bf8c33fae1fc2f82bb658f34cb56b
- Loading branch information
1 parent
b314d43
commit 4fab913
Showing
11 changed files
with
87 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,8 @@ | ||
import random | ||
#!/usr/bin/env python3 | ||
|
||
import numpy as np | ||
import pycls.core.config as config | ||
import pycls.core.distributed as dist | ||
import pycls.core.logging as logging | ||
import torch | ||
from iopath.common.file_io import g_pathmgr | ||
from pycls.core.config import cfg | ||
# Copyright (c) Facebook, Inc. and its affiliates. | ||
# | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
|
||
logger = logging.get_logger(__name__) | ||
|
||
|
||
def setup_env(): | ||
"""Sets up environment for training or testing.""" | ||
if dist.is_master_proc(): | ||
# Ensure that the output dir exists | ||
g_pathmgr.mkdirs(cfg.OUT_DIR) | ||
# Save the config | ||
config.dump_cfg() | ||
# Setup logging | ||
logging.setup_logging() | ||
# Log torch, cuda, and cudnn versions | ||
version = [torch.__version__, torch.version.cuda, torch.backends.cudnn.version()] | ||
logger.info("PyTorch Version: torch={}, cuda={}, cudnn={}".format(*version)) | ||
# Log the config as both human readable and as a json | ||
logger.info("Config:\n{}".format(cfg)) if cfg.VERBOSE else () | ||
logger.info(logging.dump_log_data(cfg, "cfg", None)) | ||
# Fix the RNG seeds (see RNG comment in core/config.py for discussion) | ||
np.random.seed(cfg.RNG_SEED) | ||
torch.manual_seed(cfg.RNG_SEED) | ||
random.seed(cfg.RNG_SEED) | ||
# Configure the CUDNN backend | ||
torch.backends.cudnn.benchmark = cfg.CUDNN.BENCHMARK | ||
"""This file is obsolete and will be removed in a future commit.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.