jiyanggao / Video-Person-ReID

Video-based Person ReID Method Implementations on MARS
381 stars 110 forks source link

what environment did you run the program? #25

Open zhangzhi-git opened 4 years ago

zhangzhi-git commented 4 years ago

Thank you for your work What environment did you run the program? Why do I use 24 GB of GPU memory and still have an out-of-memory exception when I run test。 RuntimeError: CUDA out of memory.

ZymHedy commented 3 years ago

Thank you for your work What environment did you run the program? Why do I use 24 GB of GPU memory and still have an out-of-memory exception when I run test。 RuntimeError: CUDA out of memory.

the same as you.I run test on teslap40 with 24GB,after cuda out of memory,I del imgs to release cuda memory,it works,code :

qf, q_pids, q_camids = [], [], []
    for batch_idx, (images, pids, camids) in enumerate(queryloader):
        print('{}th'.format(batch_idx))
        if use_gpu:
            imgs = images.cuda()
        del images
        # print('loader img:{}'.format(imgs.shape))
        imgs = imgs.squeeze(dim=0)
        with torch.no_grad():
            # imgs = Variable(imgs, volatile=True)  # 将imgs装进Variable中,
            # volatile=True的节点不会求导,即使requires_grad=True,也不会进行反向传播,对于不需要反向传播的情景(inference,测试推断),
            # 该参数可以实现一定速度的提升,并节省一半的显存,因为其不需要保存梯度
            # print('variable img:{}'.format(imgs.shape))
            n, s, c, h, w = imgs.size()  # b=1, n=batchs, s=图片的长度
            # assert (b == 1)  # 断言函数
            # imgs = imgs.view(b * n, s, c, h, w)
            imgs = imgs.reshape(imgs.size(0) * imgs.size(1), imgs.size(2), imgs.size(3), imgs.size(4))
            # print('view img:{}'.format(imgs.shape))

            features = model(imgs)  # 喂给模型图片,获得特征
            del imgs
            features = features.view(n, -1)  # view()函数作用是将一个多行的Tensor,拼接成一行。
            features = torch.mean(features, 0)  # 取平均值
            features = features.data.cpu()
            qf.append(features)  # 向列表尾部追加一个新元素,序列特征
            q_pids.extend(pids)  # 向列表尾部追加一个列表,人的身份person id
            q_camids.extend(camids)  # 摄像机的id
        print('unlock cuda')
        torch.cuda.empty_cache()
        print('-----------------------------------------')
    qf = torch.stack(qf)  # 堆叠
    q_pids = np.asarray(q_pids)  # 将列表转换为数组
    q_camids = np.asarray(q_camids)`

but I got a new error when computing dismat

RuntimeError: The expanded size of the tensor (9330) must match the existing size (1980) at non-singleton dimension 0. Target sizes: [9330, 1980]. Tensor sizes: [1980, 1]

ZymHedy commented 3 years ago

I still dont know how to solve this problem~have you found several better solution? @zhangzhi-git

hppy152 commented 2 years ago

Have you solved the problem now? By the way, how much RAM do you have? I never have enough RAM.

Could you help me @ZymHedy