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

Saving memory by reusing col_buffer_. #2009

Closed
wants to merge 5 commits into from
Closed

Conversation

philkr
Copy link
Contributor

@philkr philkr commented Mar 1, 2015

For fully convolutional nets the col_buffer_ in the BaseColvolutionLayer can get quite large (1GB or more in total). Currently this temporary buffer is allocated for each convolution separately. This PR introduces a TemporaryMemory class which allows all temporary memory to be shared between convolutional layers. This could be used for other layers that use temporary memory, but I couldn't find any other memory hungry ones...
This saves up to 1GB of memory for fully convolutional VGG models.

@philkr
Copy link
Contributor Author

philkr commented Mar 1, 2015

Travis seems to dislike cudaMalloc when built WITH_CUDA=true ("CUDA driver version is insufficient for CUDA runtime version"). @shelhamer any ideas on how to work around this?

@shelhamer
Copy link
Member

@philkr Check out #1291 for the quick hack edition of this idea -- although it of course does not play nicely with parallelism. Not sure what's up with Travis and cudaMalloc off the top of my head.

@philkr
Copy link
Contributor Author

philkr commented Mar 1, 2015

Currently this PR doesn't play too nicely with parallelism. It will just throw an exception if two threads are trying to access the temporary memory concurrently.
But I couldn't see where in caffe this would happen...
Edit: It now should work with concurrent memory accesses.

@nian-liu
Copy link

Hi philkr,
I have tested your code, there seems to be a bug while using cuDNN engine. When a cuDNN forward operation is runing, it will report access violation error, while the codes running well with the CAFFE engine.

@philkr
Copy link
Contributor Author

philkr commented Mar 23, 2015

@nian-liu this seems a bit odd, as cudnn doesn't seem to be using col_buffer_. What version of cuDNN are you using?
Let me see if I can install cudnn to test this...

@nian-liu
Copy link

@philkr I am using cuDNN v1.

qinhongwei pushed a commit to qinhongwei/caffe that referenced this pull request Apr 15, 2015
Saving memory by reusing col_buffer_.
elleryrussell pushed a commit to elleryrussell/caffe that referenced this pull request May 1, 2015
Saving memory by reusing col_buffer_.
@naibaf7 naibaf7 mentioned this pull request Jun 26, 2015
elleryrussell pushed a commit to elleryrussell/caffe that referenced this pull request Jul 3, 2015
Saving memory by reusing col_buffer_.
@shelhamer
Copy link
Member

Closing since master has drifted and this was always potentially a bit dangerous. Thanks for the bespoke conv memory pool all the same Philipp!

@shelhamer shelhamer closed this Apr 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants