zhihu还不错的相关介绍 不过按这个文章的说法 加速原理是开始会搜索并缓存最优的卷积结构,如果输入尺寸一直变的话,还可能变慢,看看yolov5的写法
def init_seeds(seed=0):
torch.manual_seed(seed)
# Speed-reproducibility tradeoff https://pytorch.org/docs/stable/notes/randomness.html
if seed == 0: # slower, more reproducible
cudnn.deterministic = True
cudnn.benchmark = False
else: # faster, less reproducible
cudnn.deterministic = False
cudnn.benchmark = True
v5中seed取1,不过v5的img_size固定了,不像v3