dotnet / TorchSharp

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

multi-gpu training #1369

Closed lindadamama closed 3 months ago

lindadamama commented 3 months ago

Does it support multi-gpu training? Is there any sample code?

K1T00 commented 3 months ago
var gpu0 = new Device(DeviceType.CUDA, 0);
var gpu1 = new Device(DeviceType.CUDA, 1);

var myTensor0 = torch.ones(3, 3).to(gpu0);
var myTensor1 = torch.ones(3, 3).to(gpu1);

...

I think this should work.

NiklasGustafsson commented 3 months ago

It should, but I haven't tested it myself.