Imported from https://github.com/qingzew/tensorflow-ram