Giter Site home page Giter Site logo

Multi-GPU Training about lava-dl HOT 3 CLOSED

michaelneumeier avatar michaelneumeier commented on September 26, 2024
Multi-GPU Training

from lava-dl.

Comments (3)

michaelneumeier avatar michaelneumeier commented on September 26, 2024 1

Thank you @bamsumit for the quick reply.

I cannot run the exact code that you proposed. For this I get a device mismatch between the input tensor and weight tensor. Thus I tried this:

net = Network().to(device)
net.forward(torch.rand(1, 2, 128, 128, 1).to(device))
net = nn.DataParallel(net, device_ids=[0, 1])

Then this code snippet works.

If I run it before the training loop, I can even run the training for several epochs without receiving the backprop error message from the previous comment.
But without the net.forward line, the error is still there. Do you understand why this is the case?

So thank you for the hint, I can now train on multiple GPUs.

from lava-dl.

bamsumit avatar bamsumit commented on September 26, 2024

Hi @michaelneumeier can you try this.

net = Network()
net.forward(torch.rand(1, C, H, W, 1).to(device))  # CHW = your input dimension
net = nn.DataParallel(net, device_ids=[0, 1])
net.to(device)

from lava-dl.

bamsumit avatar bamsumit commented on September 26, 2024

Glad you can run it now. The slayer models support runtime shape identification. This means that we don't need to specify the shape of a layer. Instead they are identified on runtime. With multi GPU, the shape update happens on the spawned dataparallel copy but is not reflected back on the main model, so it needs to be done on the main copy once with a dummy load before the multiGPU run. This should also work.

net = Network().to(device)
net = nn.DataParallel(net, device_ids=[0, 1])
...
net.module.forward(torch.rand(1, 2, 128, 128, 1).to(device))
# training sequence

from lava-dl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.