Giter Club home page Giter Club logo

Comments (7)

alexkoltun avatar alexkoltun commented on May 18, 2024 3

Did you restart the kernel?

I tested with the following change on a GPU machine and it works:

if torch.cuda.is_available():
    torch.set_default_tensor_type('torch.cuda.FloatTensor')
net = build_ssd('test', 300, 21)    # initialize SSD
net.load_weights('../weights/ssd300_mAP_77.43_v2.pth')
if torch.cuda.is_available():
    net = net.cuda()

from ssd.pytorch.

alexkoltun avatar alexkoltun commented on May 18, 2024 1

Most likely that the net is not on GPU, try adding the following, just after weight loading:

if torch.cuda.is_available():
    net = net.cuda()

from ssd.pytorch.

DragonBornHD avatar DragonBornHD commented on May 18, 2024

I tried this way, another error occurred:

TypeError: mul received an invalid combination of arguments - got (torch.FloatTensor), but expected one of:

  • (float value)
    didn't match because some of the arguments have invalid types: (torch.FloatTensor)
  • (torch.cuda.FloatTensor other)
    didn't match because some of the arguments have invalid types: (torch.FloatTensor)

I added the 'net = net.cuda()' after 'net.load_state_dict(torch.load(trained_model))' , and 'x = x.cuda()' after 'x = Variable(x.unsqueeze(0))' .
Thank you.

from ssd.pytorch.

alexkoltun avatar alexkoltun commented on May 18, 2024

I see.. I think setting the default tensor to be cuda might solve it, try to put the following somewhere before model loading:

if torch.cuda.is_available():
    torch.set_default_tensor_type('torch.cuda.FloatTensor')

from ssd.pytorch.

DragonBornHD avatar DragonBornHD commented on May 18, 2024

That's doesn't work, same problem.

from ssd.pytorch.

DragonBornHD avatar DragonBornHD commented on May 18, 2024

Yes it works!
torch.set_default_tensor_type('torch.cuda.FloatTensor') Should before net = build_ssd('test', 300, 21)
Thank you very much !!

from ssd.pytorch.

DonghoonPark12 avatar DonghoonPark12 commented on May 18, 2024

@alexkoltun
I'm sorry but, when I train my network on gpu by below code,

if torch.cuda.is_available():
    net = net.cuda()

Why there is another need when I'm training for example in train.py

        if args.cuda:
            images = images.cuda()
            targets = [ann.cuda() for ann in targets]
        else:
            images = images
            targets = [ann for ann in targets]

Is there also diffenrence between below two line??

images = images.cuda()
# and
images = images

Thanks ahead.

from ssd.pytorch.

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.