Skip to content

Instantly share code, notes, and snippets.

@etrulls
Last active September 17, 2015 15:09
Show Gist options
  • Save etrulls/7d99bbd1f947da62bbf8 to your computer and use it in GitHub Desktop.
Save etrulls/7d99bbd1f947da62bbf8 to your computer and use it in GitHub Desktop.
require 'cutorch'
require 'cunn'
-- problem appears with two or more layers
model = nn.Sequential()
model:add( nn.SpatialConvolution(1,10,3,3) )
model:add( nn.SpatialConvolution(10,20,3,3) )
model:cuda()
print( 'This works' )
weights, gradients = model:getParameters()
-- convert to float and store
copy = model:clone():float()
torch.save( 'copy.t7', copy )
-- load and move to GPU
stored = torch.load( 'copy.t7' )
stored:cuda()
print( 'This crashes' )
weights, gradients = stored:getParameters()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment