dotnet / TorchSharp

A .NET library that provides access to the library that powers PyTorch.
MIT License
1.37k stars 177 forks source link

Setting cuda random seed #170

Closed dsyme closed 3 years ago

dsyme commented 4 years ago

Comment from DIffsharp:

    // TODO (important): we need to do *both* this Torch.SetSeed and CUDA SetSeed when device is GPU. CPU seed and CUDA seed are handled separately in torch and libtorch.
    // However at the point of writing this comment, Cuda SetSeed was not available in TorchSharp
dsyme commented 3 years ago

@gbaydin - it looks like torch::manual_seed(seed); already does what we need here

https://pytorch.org/docs/stable/notes/randomness.html

You can use torch.manual_seed() to seed the RNG for all devices (both CPU and CUDA):