BVLC / caffe

Caffe: a fast open framework for deep learning.
http://caffe.berkeleyvision.org/
Other
34.12k stars 18.69k forks source link

Memory leak in creating network #3935

Open cirvladimir opened 8 years ago

cirvladimir commented 8 years ago

Code:

#include <iostream>
#include <caffe/caffe.hpp>

using namespace std;
using namespace caffe;

int main(int argc, char ** argv) {
    ::google::InitGoogleLogging(argv[0]);
    Net<float> net("lenet.prototxt", TRAIN);
    return 0;
}

The lenet is the one in the examples. Valgrind output:

==5510== LEAK SUMMARY:
==5510==    definitely lost: 48 bytes in 2 blocks
==5510==    indirectly lost: 0 bytes in 0 blocks
==5510==      possibly lost: 72,235,850 bytes in 20,159 blocks
==5510==    still reachable: 103,940,584 bytes in 146,205 blocks
==5510==         suppressed: 0 bytes in 0 blocks
naibaf7 commented 8 years ago

@vovakkk Does not seem to be too bad... is it with CUDA enabled? If so, check: http://stackoverflow.com/questions/20593450/valgrind-and-cuda-are-reported-leaks-real

Is it an actual issue in any use case?

cirvladimir commented 8 years ago

@naibaf7 Not an actual issue. Not sure about cuda being enabled.

ajtulloch commented 8 years ago

Another source is Protobuf - Caffe2 calls ShutdownProtobufLibrary for this reason AFAIK (https://github.com/Yangqing/caffe2/blob/d4671faaa3d9dc50bbc701d4a9dffdc9b418421b/caffe2/binaries/run_plan.cc#L18). Could you try adding that to your main and seeing if that reduces the Valgrind noise?

cirvladimir commented 8 years ago

@ajtulloch Tried putting that line in, same valgrind output.

@naibaf7 Leak is there both in GPU and CPU mode.