def logging_train_setup(args, cfg) -> None: output_dir = cfg.OUTPUT_DIR if output_dir: PathManager.mkdirs(output_dir) logger = logging.setup_logging( cfg.NUM_GPUS, get_world_size(), output_dir, name="visual_prompt") # Log basic information about environment, cmdline arguments, and config rank = get_rank() logger.info( f"Rank of current process: {rank}. World size: {get_world_size()}") logger.info("Environment info:\n" + collect_env_info()) logger.info("Command line arguments: " + str(args)) if hasattr(args, "config_file") and args.config_file != "": logger.info( "Contents of args.config_file={}:\n{}".format( args.config_file, PathManager.open(args.config_file, "r").read() ) ) # Show the config logger.info("Training with config:") logger.info(pprint.pformat(cfg)) # cudnn benchmark has large overhead. # It shouldn't be used considering the small size of typical val set. if not (hasattr(args, "eval_only") and args.eval_only): torch.backends.cudnn.benchmark = cfg.CUDNN_BENCHMARK
时间: 2023-06-24 13:05:44 浏览: 363
absl_py-2.1.0-py3-none-any.whl.zip
这段代码是用来设置训练日志的。首先,它会创建一个输出目录。然后,它会使用logging模块设置日志,其中包括环境信息、命令行参数、配置信息和当前进程的排名等。如果有配置文件,它还会将配置文件的内容记录在日志中。接着,它会显示训练配置,并设置是否使用cudnn benchmark。如果args中有eval_only属性且为True,那么不会使用cudnn benchmark。
阅读全文