Comments (3)
Hi,
Minerva keeps track of the memory using reference counting. An array in Minerva is nothing but a pointer to a memory buffer. When the reference counts of a memory buffer drops to zero (i.e, no array is pointing to the memory buffer anymore), the memory will be released. Therefore, you do not need to explicitly free memory. For example, in your example, if the data
variable is out of scope, its internal memory should be released.
So if you find the memory consumption keeps growing, you must have created too many arrays and the total memory usage is beyond the gpu memory limit, in which case there is little you could do. Please have a look at your code and calculate the total amount of memory to be used. We'd also like to have a look as well if you could narrow the problem in some short examples.
Hope this will help.
Minjie
from minerva.
Minerva has its own memory manage system. We keep a memory pool of the
freed memory blocks, and allocates from the memory pool when we need a new
memory block.
The memory corresponding to an NArray is freed to memory pool automatically
when the NArray is not referenced anymore. Manually deleting the memory of
an NArray (as you did in free_memory) is not recommended. It will confuse
the memory management system. So both pieces of your code are doomed to
fail, although the second one happened to work. :-)
A way to limit memory usage is to limit the number of "live" NArrays in
scope. NArrays that are out of scope will be automatically GCed, and memory
will be freed. You can also call Python's GC manually if you find it a
problem.
On Fri, Aug 7, 2015 at 11:33 AM, chaocliu [email protected] wrote:
Hi
Thanks for the great tool.
I are trying to use minerva to run RNN on huge-size dataset. However, the
gpu memory increase gradually and get crashed when it is beyond the gpu
memory limit. My first question is that is there any way/function to free
memory of unused variables? I have used wait_for_all, however it cannot
solve the problem.I try to write a memory-free function by cudaFree. The function is able to
free the memory of the Narray variable, however, the pointer to the Narray
variable still exists. When I reuse the Narray variable for assignment
operation recursively, e.g. data=owl.from_numpy(np.array([...])), I found
that it works for a new array with different size, however, it get crashed
when the size of new array is same as the old one that has been deleted.
For example://cannot work
data = owl.from_numpy(np.range(10000).reshape(100,100))
owl.free_memory(data) //I write the function using cudaFree by myself
data = owl.from_numpy(np.range(10000).reshape(100,100))
owl.free_memory(data) //core dump here//can work
data = owl.from_numpy(np.arange(10000).reshape(100,100))
owl.free_memory(data)
data = owl.from_numpy(np.arange(20000).reshape(200,100))
owl.free_memory(data)Would you please find out for me the reason? Thanks a lot
—
Reply to this email directly or view it on GitHub
#46.
HONG Chuntao
System Research Group
Microsoft Research Asia
from minerva.
Hi jermainewang and hjk41,
Thanks a lot for your prompt and detail reply. It is a great help for me to understand the Minerva memory management system and direct me how to revise my code. Thank you again for providing the great tool!
from minerva.
Related Issues (20)
- Does installation of Own module require dmlc? HOT 4
- Can't build apps HOT 6
- ./main: symbol lookup error: ./main: undefined symbol: _ZN7minerva13MinervaSystem15CreateCpuDeviceEv HOT 2
- Failed to run MNIST example due to CudaPerformNormAddOnRow CUDA: invalid device function HOT 1
- How is Minerva/Owl different from Theano? HOT 1
- Fast convolution using FFT HOT 1
- automatically detect GPU compute capability and set -arch correctly HOT 2
- Does Owl trainer randomly shuffle data in each epoch? HOT 2
- indexing reference of NArray? HOT 4
- Missing index 0 in CPU SoftmaxForward HOT 2
- Request owl.elewise.pow/sqrt HOT 1
- Pooling output dimension is confusing if we give a non-square matrix as input HOT 1
- broadcasting NArray + NArray HOT 2
- use_dag flag HOT 1
- race condition in owl imports
- build failed on ubuntu14.04 HOT 1
- terminate called after throwing an instance of 'std::out_of_range' HOT 7
- Binary Classifier - Log loss function HOT 1
- Differences with MShadow HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from minerva.