Pytorch ';torch.backends.cudnn.deterministic=True';和';torch.set_确定性(真)和#x27;?

Pytorch ';torch.backends.cudnn.deterministic=True';和';torch.set_确定性(真)和#x27;?,pytorch,deterministic,reproducible-research,Pytorch,Deterministic,Reproducible Research,我的网络包括'torch.nn.MaxPool3d',根据PyTorch文档(版本1.7-),当cudnn deterministic标志打开时会引发运行时错误,但是,当我在代码开头插入代码'torch.backends.cudnn.deterministic=True'时,没有运行时错误。为什么该代码不抛出运行时错误? 我想知道这段代码是否保证了我的训练过程的确定性计算。torch.backends.cudnn.deterministic=True只适用于CUDA卷积运算,其他什么都不适用。因

我的网络包括'torch.nn.MaxPool3d',根据PyTorch文档(版本1.7-),当cudnn deterministic标志打开时会引发运行时错误,但是,当我在代码开头插入代码'torch.backends.cudnn.deterministic=True'时,没有运行时错误。为什么该代码不抛出运行时错误?
我想知道这段代码是否保证了我的训练过程的确定性计算。

torch.backends.cudnn.deterministic=True只适用于CUDA卷积运算,其他什么都不适用。因此,不,它不能保证您的培训过程是确定的,因为您还使用了
torch.nn.MaxPool3d
,它的向后功能对于CUDA来说是不确定的

另一方面,
torch.set_deterministic()
影响此处列出的所有通常不确定的操作(注意,
set_deterministic
在1.8中已重命名为
use_deterministic_algorithms
):

正如文档所述,列出的一些操作没有确定性实现。因此,如果设置了
torch.use\u deterministic\u algorithms(True)
,它们将抛出一个错误

如果您需要使用非确定性操作,如
torch.nn.MaxPool3d
,那么,目前,您的培训过程无法确定——除非您自己编写自定义的确定性实现。或者,您可以打开GitHub问题,请求确定性实现:

此外,您可能希望签出此页面: