1.测试环境
cuda10.0
vscode2017
window10
cudnn7.6.5
本人的安装的包如下,其他安装需求请保持和论文一致:
colorama 0.4.6
imageio 2.31.2
networkx 2.6.3
numpy 1.21.6
packaging 23.1
Pillow 9.5.0
pip 23.2.1
PyWavelets 1.3.0
PyYAML 3.13
scikit-image 0.19.3
scipy 1.7.3
setuptools 68.1.2
six 1.16.0
smoke 0.1 d:\smoke
tifffile 2021.11.2
torch 1.3.1
torchvision 0.4.2
tqdm 4.66.1
wheel 0.41.2
yacs 0.1.8
其中pillow库版本建议使用7.0以下版本,如果想和我保持一致的话,请修改
path\torchvision\transforms\functional.py中的from PIL import Image, ImageOps, ImageEnhance, __version__ 替换文件中from PIL import Image, ImageOps, ImageEnhance,PILLOW_VERSION这句。
之后修改 path\smoke\smoke\engine\defaults.py这一文件
import argparse
import os
import random
import torch
from smoke.utils import comm
from smoke.utils.miscellaneous import mkdir
from smoke.utils.logger import setup_logger
from smoke.utils.collect_env import collect_env_info
from smoke.utils.envs import seed_all_rng
__all__ = ["default_argument_parser", "default_setup"]
def default_argument_parser():
parser = argparse.ArgumentParser(description="Detectron2 Training")
parser.add_argument("--config-file", default="configs/smoke_gn_vector.yaml",
metavar="FILE", help="path to config file")
parser.add_argument("--eval-only", action="store_true", help="perform evaluation only")
parser.add_argument(
"--ckpt",
help="The path to the checkpoint for test, default is the latest checkpoint.",
default=None,
)
parser.add_argument("--num-gpus", type=int, default=1, help="number of gpus *per machine*")
parser.add_argument("--num-machines", type=int, default=1)
parser.add_argument(
"--machine-rank", type=int, default=0, help="the rank of this machine (unique per machine)"
)
# PyTorch still may leave orphan processes in multi-gpu training.
# Therefore we use a deterministic way to obtain port,
# so that users are aware of orphan processes by seeing the port occupied.
port = 2 ** 15 + 2 ** 14 + random.randint(0, 2 ** 14)
parser.add_argument("--dist-url", default="tcp://127.0.0.1:{}".format(port))
parser.add_argument(
"opts",
help="Modify config options using the command-line",
default=None,
nargs=argparse.REMAINDER,
)
return parser
def default_setup(cfg, args):
output_dir = cfg.OUTPUT_DIR
if output_dir:
mkdir(output_dir)
rank = comm.get_rank()
logger = setup_logger(output_dir, rank)
logger.info("Using {} GPUs".format(args.num_gpus))
logger.info("Collecting environment info")
logger.info("\n" + collect_env_info())
logger.info(args)
logger.info("Loaded configuration file {}".format(args.config_file))
with open(args.config_file, "r") as cf:
config_str = "\n" + cf.read()
logger.info(config_str)
logger.info("Running with config:\n{}".format(cfg))
# make sure each worker has a different, yet deterministic seed if specified
seed_all_rng(None if cfg.SEED < 0 else cfg.SEED + rank)
# cudnn benchmark has large overhead. It shouldn't be used considering the small size of
# typical validation set.
if not (hasattr(args, "eval_only") and args.eval_only):
torch.backends.cudnn.benchmark = cfg.CUDNN_BENCHMARK
通过使用random.randint()
函数生成一个随机端口号 来替代原文件中os.getuid()
函数来生成一个端口号这个功能,到此修改完毕,接下来就可以在window上进行SMOKE论文复现啦。