4 GPUs on my machine ,GPU 0 and 1 is running other’s code with nearly full memory usage.
So I use GPU 2 and 3. But when I run it ,it still reports
RuntimeError: CUDA out of memory. Tried to allocate 512.00 MiB (GPU 0; 10.92 GiB total capacity; 10.21 GiB already allocated; 89.50 MiB free; 9.64 MiB cached)

Here I post my dataparallel code:
os.environ['CUDA_DEVICE_ORDER']='PCI_BUS_ID'
os.environ['CUDA_VISIBLE_DEVICES']='2,3'
#this function is listed below
model=DataParallelModel(model,cuda=0,device_ids=[0,1],output_device=0)
device=torch.device('cuda:0')

#This DataParallelModel function wrap the DataParallel class 
def DataParallelModel(model,**kwargs):
        if 'device_ids' in kwargs.keys():
            device_ids = kwargs['device_ids']
        else:
            device_ids = None
        if 'output_device' in kwargs.keys():
            output_device = kwargs['output_device']
        else:
            output_device = None
        if 'cuda' in kwargs.keys():
            cudaID = kwargs['cuda']
            device=torch.device('cuda:{}'.format(cudaID))
            model = torch.nn.DataParallel(model, device_ids=device_ids, output_device=output_device).to(device)
        else:
            model = torch.nn.DataParallel(model, device_ids=device_ids, output_device=output_device).cuda()
        return model

These environ code do works,they makes my code sees gpu 2 and 3.But it still fail for such error mentioned before.
My Pytorch version is the newly released 1.0, I just upgraded it yesterday morning.