# torch.nn.DataParallel with device\_ids problem?

**URL:** <https://discuss.pytorch.org/t/torch-nn-dataparallel-with-device-ids-problem/10260>\
**Category:** Uncategorized\
**Created:** [November 22, 2017, 12:34pm UTC](https://discuss.pytorch.org/t/torch-nn-dataparallel-with-device-ids-problem/10260 "2017-11-22T12:34:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ucassdlfj](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ucassdlfj/32/2391_2.png) [@ucassdlfj](https://discuss.pytorch.org/u/ucassdlfj)\
**Post date:** [November 22, 2017, 12:34pm UTC](https://discuss.pytorch.org/t/torch-nn-dataparallel-with-device-ids-problem/10260/1 "2017-11-22T12:34:25Z")

</div>

when I use the torch.nn.DataParallel use train the network on multi-gpu,an error happened:

 ![QQ截图20171122202717](https://discuss.pytorch.org/uploads/default/original/2X/d/dc53f2d5456b83533a2d67d24b93e208b2b3d735.png)  
when I set model = torch.nn.DataParallel(net,device\_ids=[0,1]) ,there are no errors, but when I set device\_ids = [2,3] or other situation which doesn’t include the ‘0’ device, there is an error where the loss.backward(), I wonder if anyone run into this problem. How to solve this?
