Skip to content

Instantly share code, notes, and snippets.

@fmassa
Created August 10, 2016 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fmassa/cb69be37970ce8cbd42e278767017b08 to your computer and use it in GitHub Desktop.
Save fmassa/cb69be37970ce8cbd42e278767017b08 to your computer and use it in GitHub Desktop.
Test script to verify that ResNet101 fits in memory with batch size 64 with latest optnet
local optnet = require 'optnet'
require 'cudnn'
require 'cunn'
local createModel = require 'resnet'
local opt = {dataset='imagenet', depth=101}
local model = createModel(opt)
local input = torch.zeros(4,3,224,224):cuda()
local grad = torch.zeros(4, 1000):cuda()
model:forward(input)
model:backward(input, grad)
print(optnet.countUsedMemory(model))
optnet.optimizeMemory(model, input, {mode='training', inplace=false})
collectgarbage()
collectgarbage()
print(optnet.countUsedMemory(model))
input = torch.zeros(64,3,224,224):cuda()
grad = torch.zeros(64, 1000):cuda()
model:forward(input)
model:backward(input, grad)
print(optnet.countUsedMemory(model))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment