Skip to content

Commit

Permalink
tweak GPU setup in train
Browse files Browse the repository at this point in the history
  • Loading branch information
jcjohnson committed Feb 16, 2016
1 parent 0be9f67 commit 0f728e4
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions train.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,26 @@ local opt = cmd:parse(arg)

-- Set up GPU stuff
local dtype = 'torch.FloatTensor'
if opt.gpu < 0 then
-- Memory benchmarking is only supported in CUDA mode
opt.memory_benchmark = 0
print 'Running in CPU mode'
elseif opt.gpu >= 0 and opt.gpu_backend == 'cuda' then
if opt.gpu >= 0 and opt.gpu_backend == 'cuda' then
require 'cutorch'
require 'cunn'
cutorch.setDevice(opt.gpu + 1)
dtype = 'torch.CudaTensor'
print(string.format('Running with CUDA on GPU %d', opt.gpu))
elseif opt.gpu >= 0 and opt.gpu_backend == 'opencl' then
-- Disabling OpenCL support for now because nn.LookupTable is broken in clnn.
assert(false, 'OpenCL backend is not supported yet. Sorry!')
assert(false, 'OpenCL training is not supported yet. Sorry!')
-- Memory benchmarking is only supported in CUDA mode
-- TODO: Time benchmarking is probably wrong in OpenCL mode.
require 'cltorch'
require 'clnn'
cltorch.setDevice(opt.gpu + 1)
dtype = torch.Tensor():cl():type()
print(string.format('Running with OpenCL on GPU %d', opt.gpu))
else
-- Memory benchmarking is only supported in CUDA mode
opt.memory_benchmark = 0
print 'Running in CPU mode'
end


Expand Down

0 comments on commit 0f728e4

Please sign in to comment.