0
点赞
收藏
分享

微信扫一扫

Blender插入关键帧的位置报错

目录

随机种子设置(CPU操作)

GPU随机种子设置(GPU操作)

GPU操作确定性设置


随机种子设置(CPU操作)

torch.manual_seed(42)  # Setting the seed

当产生随机数的时候,CPU和GPU之间的随机种子并不同步,因此,还需要另外设置GPU上面的随机种子,确保代码可复现。

GPU随机种子设置(GPU操作)

# GPU operations have a separate seed we also want to set
if torch.cuda.is_available():
    torch.cuda.manual_seed(42)
    torch.cuda.manual_seed_all(42)

GPU操作确定性设置

在GPU上面,有些操作是为了运行效率,是随机执行的,但是为了保证后期代码在同一个机器上面可复现,会额外设置所有GPU上面的操作,都尽可能是确定性的。

# Additionally, some operations on a GPU are implemented stochastic for efficiency
# We want to ensure that all operations are deterministic on GPU (if used) for reproducibility
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
举报

相关推荐

0 条评论