kewin1807 / table-recognition

8 stars 4 forks source link

CUDA out of memory while running test.py #1

Open sindhurk opened 3 years ago

sindhurk commented 3 years ago

While running test.py with the following code: python test.py --img pubtabnet/val/PMC524480_006_00.png --model BEST_checkpoint_table.pth.tar --word_map_structure output/WORDMAP_STRUCTURE.json --word_map_cell output/WORDMAP_CELL.json I get the following error. I tried in colab, with 32G memory and get a similar error. Here is the error msg:

test.py:18: DeprecationWarning:     `imread` is deprecated!
    `imread` is deprecated in SciPy 1.0.0, and will be removed in 1.2.0.
    Use ``imageio.imread`` instead.
  img = imread(image_path)
test.py:22: DeprecationWarning:     `imresize` is deprecated!
    `imresize` is deprecated in SciPy 1.0.0, and will be removed in 1.2.0.
    Use ``skimage.transform.resize`` instead.
  img = imresize(img, (height_image, width_image))
Traceback (most recent call last):
  File "test.py", line 363, in <module>
    seq, alphas, hidden_states = structure_image_beam_search(encoder_out, decoder_structure, word_map_structure, beam_size=args.beam_size_structure)
  File "test.py", line 90, in structure_image_beam_search
    awe, alpha = decoder.attention(encoder_out, h)
  File "/home/sindhu/anaconda3/envs/py37/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/sindhu/projects/tab2html/table-recognition/code/image_caption/models.py", line 88, in forward
    att1 = self.encoder_att(encoder_out)  # (batch_size, num_pixels, attention_dim)
  File "/home/sindhu/anaconda3/envs/py37/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/sindhu/anaconda3/envs/py37/lib/python3.7/site-packages/torch/nn/modules/linear.py", line 93, in forward
    return F.linear(input, self.weight, self.bias)
  File "/home/sindhu/anaconda3/envs/py37/lib/python3.7/site-packages/torch/nn/functional.py", line 1692, in linear
    output = input.matmul(weight.t())
RuntimeError: CUDA out of memory. Tried to allocate 20.00 MiB (GPU 0; 3.82 GiB total capacity; 2.64 GiB already allocated; 27.12 MiB free; 2.65 GiB reserved in total by PyTorch)
kewin1807 commented 3 years ago

You can show config GPU what you used. i tested in GPU which VRAM is 11GB and it worked !!

sindhurk commented 3 years ago

Well, my vram is 4gb. Also, what is the accuracy you are getting with your model and how many epochs did you train?

kewin1807 commented 3 years ago

I have just trained 10 epochs, after train my TED SCORE is 0.62, it is very different from papers. This repo is my base implementation for paper, you can config and edit to get higher score.

sindhurk commented 3 years ago

Can you pls share your trained weights file. My mail id is sindhuraman610@gmail.com

sindhuattaiger commented 3 years ago

replace model.eval() with torch.no_grad() and it works on my machine with 4gb vram