CUDA out of memory
- Hello, I am trying to fine tune the data using ct-vocabfine_train.exe. I only included 4 samples of data, and my graphics card is A40 45GB. I set batch size=1 but still have memory overflow. I would like to know what the minimum memory requirement for this task is, 80GB?
- Also, although I only have 45GB of video memory, I have 6 of them, so can I use them to run the code smoothly!
thank you!
Fine-tuning end-to-end
to_text_latent.weight torch.Size([512, 768])
to_visual_latent.weight torch.Size([512, 294912])
to_text_latent_extra.weight torch.Size([512, 768])
to_visual_latent_extra.weight torch.Size([512, 294912])
100%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 2/2 [00:00<00:00, 859.66it/s]
four
0it [00:00, ?it/s]testmem
test all pooling
testmem
test all pooling
testmem
test all pooling
testmem
test all pooling
testmem
0it [00:06, ?it/s]
Traceback (most recent call last):
File "ct_vocabfine_train.py", line 187, in
finetune(args)
File "ct_vocabfine_train.py", line 120, in finetune
output = model(text_tokens, inputs, device=torch.device('cuda'))
File "/home/yan/anaconda3/envs/CT-CLIP/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/yan/anaconda3/envs/CT-CLIP/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py", line 169, in forward
return self.module(*inputs[0], **kwargs[0])
File "/home/yan/anaconda3/envs/CT-CLIP/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/yan/project10/CT-CLIP-main/CT_CLIP/ct_clip/ct_clip.py", line 753, in forward
enc_image = self.visual_transformer(image, return_encoded_tokens=True)
File "/home/yan/anaconda3/envs/CT-CLIP/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/yan/project10/CT-CLIP-main/transformer_maskgit/transformer_maskgit/ctvit.py", line 414, in forward
tokens = self.encode(tokens)
File "/home/yan/project10/CT-CLIP-main/transformer_maskgit/transformer_maskgit/ctvit.py", line 314, in encode
attn_bias = self.spatial_rel_pos_bias(h, w, device=device)
File "/home/yan/anaconda3/envs/CT-CLIP/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/yan/project10/CT-CLIP-main/transformer_maskgit/transformer_maskgit/attention.py", line 274, in forward
rel_pos = layer(rel_pos.float())
File "/home/yan/anaconda3/envs/CT-CLIP/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/yan/anaconda3/envs/CT-CLIP/lib/python3.8/site-packages/torch/nn/modules/container.py", line 217, in forward
input = module(input)
File "/home/yan/anaconda3/envs/CT-CLIP/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/yan/anaconda3/envs/CT-CLIP/lib/python3.8/site-packages/torch/nn/modules/activation.py", line 777, in forward
return F.leaky_relu(input, self.negative_slope, self.inplace)
File "/home/yan/anaconda3/envs/CT-CLIP/lib/python3.8/site-packages/torch/nn/functional.py", line 1632, in leaky_relu
result = torch._C._nn.leaky_relu(input, negative_slope)
torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 648.00 MiB (GPU 0; 44.34 GiB total capacity; 43.62 GiB already allocated; 53.31 MiB free; 43.94 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF