I am using pytorch and I wonder if I should use torch.backends.cudnn.benchmark = True
. I find on google that I should use it when computation graph does not change. What is computation graph in pytorch?
It enables benchmark mode in cudnn. benchmark mode is good whenever your input sizes for your network do not vary. This way, cudnn will look for the optimal set of algorithms for that particular configuration (which takes some time). This usually leads to faster runtime.
If you are using the PyTorch binaries, they come with cuda and cuDNN built in.
The cuDNN library is not mandatory, but required for full keypoint detection accuracy. In case your graphics card is not compatible with cuDNN, you can disable it by unchecking USE_CUDNN in CMake.
cudnn. deterministic = True is set. The latter setting controls only this behavior, unlike torch. use_deterministic_algorithms() which will make other PyTorch operations behave deterministically, too.
If your model does not change and your input sizes remain the same - then you may benefit from setting torch.backends.cudnn.benchmark = True
.
However, if your model changes: for instance, if you have layers that are only "activated" when certain conditions are met, or you have layers inside a loop that can be iterated a different number of times, then setting torch.backends.cudnn.benchmark = True
might stall your execution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With