Skip to content

Commit

Permalink
handle GPU err on
Browse files Browse the repository at this point in the history
use_deterministic_algorithms
  • Loading branch information
aash1999 committed Oct 21, 2023
1 parent 16fd02c commit 7eff0ef
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7eff0ef

Please sign in to comment.