为什么 torch.randn 不能在所有播种中重现?

Why is torch.randn not been reproducible with all seeding?

提问人:amew646 提问时间:11/2/2023 最后编辑:amew646 更新时间:11/2/2023 访问量:46

问:

标题说明了一切,这是我的问题:

我希望是可重复的。torch.randn(1)

我正在使用: CUDA:12.1 TCC/WDDM系列 VS Code Jupyter 并尝试了以下方法。seed

seed=42
torch.manual_seed(seed=seed)
torch.cuda.manual_seed_all(seed=seed)
np.random.seed(seed=seed)
torch.backends.cudnn.deterministic = True
torch.use_deterministic_algorithms(True)
torch.backends.cudnn.benchmark = False 

torch.randn(1)

我第一次单独尝试,但无法重现。torch.manual_seed(seed=seed)

我期望有一个常量值作为输出。

蟒蛇 火炬 随机种子

评论

1赞 Nick ODell 11/2/2023
torch.manual_seed(seed=seed)足以在我的系统上实现可重复性。这可能是特定于硬件的错误吗?
0赞 amew646 11/2/2023
好吧,我只是在另一台机器上单独尝试了您的评论,但它仍然不可重现。
1赞 Nick ODell 11/3/2023
是特定于操作系统的错误吗?我在 Linux 上运行了我的测试。
0赞 amew646 11/24/2023
是的,我相信是这样。我清除了所有缓存并重新启动了我的设备,我能够用我的种子重现它。

答: 暂无答案