Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

out of memory when extracting patches from Oxford dataset #5

Closed
SikaStar opened this issue Mar 18, 2018 · 4 comments
Closed

out of memory when extracting patches from Oxford dataset #5

SikaStar opened this issue Mar 18, 2018 · 4 comments

Comments

@SikaStar
Copy link

Hi,
I have used your code from examples/hesaffnet/WBS demo.ipynb'to extract patches and descriptors from the Oxford dataset, however when I set USE_CUDA = True, num_features=3000, the error follows:

Traceback (most recent call last):
  File "/home/dyx/workspace/affnet/examples/hesaffnet/123.py", line 103, in <module>
    detector_time, descriptors_time = get_geometry_and_descriptors(img, detector, descriptor)
  File "/home/dyx/workspace/affnet/examples/hesaffnet/123.py", line 69, in get_geometry_and_descriptors
    patches = detector.extract_patches_from_pyr(LAFs, PS = 32)
  File "/home/dyx/workspace/affnet/examples/hesaffnet/SparseImgRepresenter.py", line 178, in extract_patches_from_pyr
    PS = PS)
  File "/home/dyx/workspace/affnet/examples/hesaffnet/LAF.py", line 218, in extract_patches_from_pyramid_with_inv_index
    patches[cur_lvl_idxs,:,:,:] = extract_patches(scale_pyramid[i][j], LAFs[cur_lvl_idxs, :,:], PS )
  File "/home/dyx/workspace/affnet/examples/hesaffnet/LAF.py", line 200, in extract_patches
    return torch.nn.functional.grid_sample(img.expand(grid.size(0), ch, h, w),  grid)  
  File "/home/dyx/anaconda2/lib/python2.7/site-packages/torch/nn/functional.py", line 995, in grid_sample
    return GridSampler.apply(input, grid)
  File "/home/dyx/anaconda2/lib/python2.7/site-packages/torch/nn/_functions/vision.py", line 27, in forward
    input = input.contiguous()
RuntimeError: cuda runtime error (2) : out of memory at /opt/conda/conda-bld/pytorch_1503966894950/work/torch/lib/THC/generic/THCStorage.cu:66

Process finished with exit code 1

and when I set num_features=1000 it will be OK, could you tell me how to solve it?
Thanks a lot!

@ducha-aiki
Copy link
Owner

That seems that you don`t have enough GPU memory. The only solution is to set USE_CUDA to False.

I have an implementation, which do things is batches, but it works only with latest github PyTorch, not pip one. So if I apply changes, it would break compatibility, which I don`t want
But you can try to replace all grid_apply functions with this one:

https://gist.github.com/ducha-aiki/9f457f80298c52aa65819fe235f9cec1

@SikaStar SikaStar reopened this Mar 18, 2018
@SikaStar
Copy link
Author

@ducha-aiki
That's great! Thank you very much!

@gsygsy96
Copy link

gsygsy96 commented May 5, 2018

Can't reach your address ---- 'https://gist.github.com/ducha-aiki/9f457f80298c52aa65819fe235f9cec1'
Could u give me the updated address? @SikaStar @ducha-aiki

@ducha-aiki
Copy link
Owner

@shanYanGuan address you have works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants