diff --git a/modules/devices.py b/modules/devices.py index c35c8b909..0c5fb1552 100644 --- a/modules/devices.py +++ b/modules/devices.py @@ -395,10 +395,10 @@ def set_cudnn_params(): torch.use_deterministic_algorithms(opts.cudnn_deterministic) if opts.cudnn_deterministic: os.environ.setdefault('CUBLAS_WORKSPACE_CONFIG', ':4096:8') - torch.backends.cudnn.benchmark = True + torch.backends.cudnn.benchmark = opts.cudnn_benchmark if opts.cudnn_benchmark: log.debug('Torch cuDNN: enable benchmark') - torch.backends.cudnn.benchmark_limit = 0 + torch.backends.cudnn.benchmark_limit = opts.cudnn_benchmark_limit torch.backends.cudnn.allow_tf32 = True except Exception as e: log.warning(f'Torch cudnn: {e}') diff --git a/modules/shared.py b/modules/shared.py index 884ca3154..b1faa53ba 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -482,9 +482,10 @@ options_templates.update(options_section(('backends', "Backend Settings"), { "other_sep": OptionInfo("

Torch Options

", "", gr.HTML), "opt_channelslast": OptionInfo(False, "Channels last "), "cudnn_deterministic": OptionInfo(False, "Deterministic mode"), - "cudnn_benchmark": OptionInfo(False, "Full-depth cuDNN benchmark"), "diffusers_fuse_projections": OptionInfo(False, "Fused projections"), "torch_expandable_segments": OptionInfo(False, "Expandable segments"), + "cudnn_benchmark": OptionInfo(devices.backend != "rocm", "Full-depth cuDNN benchmark"), + "cudnn_benchmark_limit": OptionInfo(10, "cuDNN benchmark limit", gr.Slider, {"minimum": 0, "maximum": 100, "step": 1}), "torch_tunable_ops": OptionInfo("default", "Tunable ops", gr.Radio, {"choices": ["default", "true", "false"]}), "torch_tunable_limit": OptionInfo(30, "Tunable ops limit", gr.Slider, {"minimum": 1, "maximum": 100, "step": 1}), "cuda_mem_fraction": OptionInfo(0.0, "Memory limit", gr.Slider, {"minimum": 0, "maximum": 2.0, "step": 0.05}),