-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tensors are on different GPUs #32
Comments
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() |
I tried this way, another error occurred: TypeError: mul received an invalid combination of arguments - got (torch.FloatTensor), but expected one of:
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))' . |
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') |
That's doesn't work, same problem. |
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() |
Yes it works! |
@alexkoltun 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. |
I run the demo, return 'tensors are on different GPSs' , but I have only one GPU.
The demo was run successfully with CPU.
Can you put the process of using the GPU to release it?
Thank you very much!
The text was updated successfully, but these errors were encountered: