zhmiao / OpenLongTailRecognition-OLTR

Pytorch implementation for "Large-Scale Long-Tailed Recognition in an Open World" (CVPR 2019 ORAL)
BSD 3-Clause "New" or "Revised" License
839 stars 128 forks source link

Multiple-GPU support? #35

Closed BIGBALLON closed 4 years ago

BIGBALLON commented 5 years ago

@liuziwei7 @zhmiao thanks for your amazing work, from the CAUTION

The current code was prepared using single GPU. The use of multi-GPU can cause problems.

and the error is:

File "./models/MetaEmbeddingClassifier.py", line 48, in forward
    memory_feature = torch.matmul(values_memory, keys_memory)
RuntimeError: size mismatch, m1: [16 x 7], m2: [4 x 512] at /pytorch/aten/src/THC/generic/THCTensorMathBlas.cu:268

# for 2 GPUs:
torch.Size([16, 7])
torch.Size([3, 512])
torch.Size([16, 7])
torch.Size([4, 512])

# for 1 GPU:
torch.Size([32, 7])
torch.Size([7, 512])

Is there any idea to support Multiple-GPU?

zhmiao commented 5 years ago

Hello @BIGBALLON thank you very much for asking. We are very sorry that the current code does not support multi gpu. And the error you reported is the reason. You are very welcome to modify the code and make it working for multi-gpus.

GuohongLi commented 4 years ago

@BIGBALLON I have modified it to fit multi-gpus. Maybe it will helpful to u. L133~135 in https://github.com/GuohongLi/OpenLongTailRecognition-OLTR/blob/master/run_networks.py

BIGBALLON commented 4 years ago

@GuohongLi thanks for your help !!! 😸