GithubHelp home page GithubHelp logo

Comments (9)

ksemianov avatar ksemianov commented on May 28, 2024 2

@joeyhng: try model:zeroGradParameters() instead of grad_params:zero()

from torchnet.

lvdmaaten avatar lvdmaaten commented on May 28, 2024

I may be wrong here, but it appears you're adding the network only to the second GPU, not to the first one? Can you try something like:

if nGPU > 1 then
   local singlemodel = model
   local model = nn.DataParallelTable(1, true, false)
   for i = 1, nGPU do
      cutorch.setDevice(i)
      model:add(singlemodel:clone():cuda(), i)
   end
   cutorch.setDevice(1)
end

from torchnet.

joeyhng avatar joeyhng commented on May 28, 2024

I think the way to use multiple GPU should be correct. I'm just following fb.resnet.torch
https://github.com/facebook/fb.resnet.torch/blob/master/models/init.lua#L81

from torchnet.

lvdmaaten avatar lvdmaaten commented on May 28, 2024

I tried running the code example in your post, but I can not reproduce the issue you are seeing. Output:

Number of parameters:   11184650
iteration 1: loss=2.352886
iteration 2: loss=2.275253
iteration 3: loss=2.204911
iteration 4: loss=2.140517
iteration 5: loss=2.081086

from torchnet.

lvdmaaten avatar lvdmaaten commented on May 28, 2024

Closing this for lack of a repro or response.

from torchnet.

foelin avatar foelin commented on May 28, 2024

Have you solved the problem? I also get nan when training with multiple GPU.
Thanks

from torchnet.

joeyhng avatar joeyhng commented on May 28, 2024

from torchnet.

joeyhng avatar joeyhng commented on May 28, 2024

That seems to be the reason. It's fixed for me now. Thanks very much!!

from torchnet.

foelin avatar foelin commented on May 28, 2024

it also works for me! Thanks!

from torchnet.

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.