Code Monkey home page Code Monkey logo

mxnet-memonger's Introduction

MXNet Memory Monger

This project contains a 150 lines of python script to give sublinear memory plans of deep neural networks. This allows you to trade computation for memory and get sublinear memory cost, so you can train bigger/deeper nets with limited resources.

Reference Paper

Training Deep Nets with Sublinear Memory Cost Arxiv 1604.06174

How to Use

This code is based on MXNet, a lightweight, flexible and efficient framework for deep learning.

  • Configure your network as you normally will do using symbolic API
  • Give hint to the allocator about the possible places that we need to bookkeep computations.
    • Set attribute mirror_stage='True', see example_resnet.py
    • The memonger will try to find possible dividing points on the nodes that are annotated as mirror_stage.
  • Call memonger.search_plan to get an symbolic graph with memory plan.
import mxnet as mx
import memonger

# configure your network
net = my_symbol()

# call memory optimizer to search possible memory plan.
net_planned = memonger.search_plan(net)

# use as normal
model = mx.FeedForward(net_planned, ...)
model.fit(...)

Write your Own Memory Optimizer

MXNet's symbolic graph support attribute to give hint on whether (mirror attribute) a result can be recomputed or not. You can choose to re-compute instead of remembering a result for less memory consumption. To set output of a symbol to be re-computable, use

sym._set_attr(force_mirroring='True')

mxnet-memonger actually use the same way to do memory planning. You can simply write your own memory allocator by setting the force_mirroring attribute in a smart way.

mxnet-memonger's People

Contributors

tqchen avatar antinucleon avatar robindong avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.