aboutsummaryrefslogtreecommitdiff
path: root/nerv/nerv
diff options
context:
space:
mode:
Diffstat (limited to 'nerv/nerv')
-rw-r--r--nerv/nerv9
1 files changed, 5 insertions, 4 deletions
diff --git a/nerv/nerv b/nerv/nerv
index 9295290..0b75a9b 100644
--- a/nerv/nerv
+++ b/nerv/nerv
@@ -24,15 +24,16 @@ local function _add_profile_method(cls)
end
if not opts["use-cpu"].val then
+ local dev = -1
+ if opts["select-gpu"].val then
+ dev = opts["select-gpu"].val
+ end
nerv.info("automatically initialize a default CuContext...")
- nerv.CuMatrix._default_context = nerv.CuContext()
+ nerv.CuMatrix._default_context = nerv.CuContext(dev)
nerv.info("the default CuContext is ok")
_add_profile_method(nerv.CuMatrix)
nerv.CuMatrix.select_gpu =
function (dev) nerv.CuMatrix._default_context:select_gpu(dev) end
- if opts["select-gpu"].val then
- nerv.CuMatrix.select_gpu(opts["select-gpu"].val)
- end
end
nerv.info("automatically initialize a default MContext...")