From 7eff0ef6f04d79735d3bfad3a2a77c07c5bbee91 Mon Sep 17 00:00:00 2001 From: Aakash Singh Date: Sat, 21 Oct 2023 22:25:40 +0530 Subject: [PATCH] handle GPU err on use_deterministic_algorithms --- utils/general.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/general.py b/utils/general.py index 135141e21436..ba799a174039 100644 --- a/utils/general.py +++ b/utils/general.py @@ -264,7 +264,8 @@ def init_seeds(seed=0, deterministic=False): torch.cuda.manual_seed_all(seed) # for Multi-GPU, exception safe # torch.backends.cudnn.benchmark = True # AutoBatch problem https://github.com/ultralytics/yolov5/issues/9287 if deterministic and check_version(torch.__version__, '1.12.0'): # https://github.com/ultralytics/yolov5/pull/8213 - torch.use_deterministic_algorithms(True) + # torch.use_deterministic_algorithms(True) + torch.use_deterministic_algorithms(False, warn_only= True) #since nn.AdaptiveAvgPool2d doesn't have backward implementation during GPU training torch.backends.cudnn.deterministic = True os.environ['CUBLAS_WORKSPACE_CONFIG'] = ':4096:8' os.environ['PYTHONHASHSEED'] = str(seed)