Created
June 6, 2016 13:14
-
-
Save Kaixhin/68ffc5a2d1a69cc1556f1b2d2f1ae345 to your computer and use it in GitHub Desktop.
Basic Torch cuDNN example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'cunn' | |
local cudnn = require 'cudnn' | |
local X = torch.rand(32, 3, 24, 24):cuda() | |
local Y = torch.ones(32):cuda() | |
local net = nn.Sequential() | |
net:add(cudnn.SpatialConvolution(3, 8, 5, 5)) | |
net:add(nn.View(8*20*20)) | |
net:add(nn.Linear(8*20*20, 10)) | |
net:add(nn.LogSoftMax()) | |
net:cuda() | |
local criterion = nn.ClassNLLCriterion():cuda() | |
local output = net:forward(X) | |
local loss = criterion:forward(output, Y) | |
print(loss) |
@karandwivedi42 yes - a cudnn module is used in line 8. You can add cudnn modules manually rather than having to call cudnn.convert.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just wondering: does this use cudnn..because cudnn.convert(net,cudnn) is not called.