提交 5639c0f0 authored 作者: Frederic Bastien's avatar Frederic Bastien

Raise min cudnn version to v4. Better report of the problem when not used.

上级 ef0fc56e
...@@ -270,14 +270,14 @@ from theano.sandbox.cuda.type import CudaNdarrayType ...@@ -270,14 +270,14 @@ from theano.sandbox.cuda.type import CudaNdarrayType
def dnn_available(): def dnn_available():
if config.dnn.enabled == "False": if config.dnn.enabled == "False":
dnn_available.avail = False dnn_available.avail = False
dnn_available.msg = "disabled by dnn.enabled flag" dnn_available.msg = "Disabled by dnn.enabled flag"
if dnn_available.avail is None and not cuda_available: if dnn_available.avail is None and not cuda_available:
dnn_available.msg = "CUDA not available" dnn_available.msg = "CUDA not available"
dnn_available.avail = False dnn_available.avail = False
elif dnn_available.avail is None: elif dnn_available.avail is None:
dev = active_device_number() dev = active_device_number()
if device_properties(dev)['major'] < 3: if device_properties(dev)['major'] < 3:
dnn_available.msg = "Device not supported by cuDNN" dnn_available.msg = "Device not supported"
dnn_available.avail = False dnn_available.avail = False
else: else:
preambule = """ preambule = """
...@@ -315,7 +315,7 @@ if ((err = cudnnCreate(&_handle)) != CUDNN_STATUS_SUCCESS) { ...@@ -315,7 +315,7 @@ if ((err = cudnnCreate(&_handle)) != CUDNN_STATUS_SUCCESS) {
dnn_available.avail = comp dnn_available.avail = comp
if not dnn_available.avail: if not dnn_available.avail:
dnn_available.msg = ( dnn_available.msg = (
"Theano can not compile with cuDNN. We got this error:\n" + "Can not compile with cuDNN. We got this error:\n" +
str(err)) str(err))
else: else:
# If we can compile, check that we can import and run. # If we can compile, check that we can import and run.
...@@ -326,13 +326,10 @@ if ((err = cudnnCreate(&_handle)) != CUDNN_STATUS_SUCCESS) { ...@@ -326,13 +326,10 @@ if ((err = cudnnCreate(&_handle)) != CUDNN_STATUS_SUCCESS) {
" from one version, but we link with" " from one version, but we link with"
" a different version %s" % str(v)) " a different version %s" % str(v))
raise RuntimeError(dnn_available.msg) raise RuntimeError(dnn_available.msg)
if v == -1 or v[0] < 3007: if v == -1 or v[0] < 4007:
# 3007 is the final release of cudnn v3 # 4007 is the final release of cudnn v4
dnn_available.avail = False dnn_available.avail = False
dnn_available.msg = ( dnn_available.msg = "Version too old. Update to v5."
"You have an old release of CuDNN (or a release "
"candidate) that isn't supported. Please update to "
"at least v3 final version.")
raise RuntimeError(dnn_available.msg) raise RuntimeError(dnn_available.msg)
if config.dnn.enabled == "True": if config.dnn.enabled == "True":
if not dnn_available.avail: if not dnn_available.avail:
...@@ -582,13 +579,13 @@ def use(device, ...@@ -582,13 +579,13 @@ def use(device,
if dnn_available(): if dnn_available():
(hdr_v, runtime_v) = dnn_version() (hdr_v, runtime_v) = dnn_version()
cudnn_version = runtime_v cudnn_version = runtime_v
# 4100 should not print warning with cudnn 4 final. # 5100 should not print warning with cudnn 5 final.
if cudnn_version > 4100: if cudnn_version > 5100:
warn = ("Your CuDNN version is more recent then Theano." warn = ("Your CuDNN version is more recent then Theano."
" If you see problems, try updating Theano or" " If you see problems, try updating Theano or"
" downgrading CuDNN to version 4.") " downgrading CuDNN to version 5.")
except Exception: except Exception:
pass cudnn_version = dnn_available.msg
print("Using gpu device %d: %s (CNMeM is %s, CuDNN %s)" % ( print("Using gpu device %d: %s (CNMeM is %s, CuDNN %s)" % (
active_device_number(), active_device_number(),
active_device_name(), active_device_name(),
......
...@@ -71,14 +71,14 @@ def init_dev(dev, name=None): ...@@ -71,14 +71,14 @@ def init_dev(dev, name=None):
cudnn_version = " (CuDNN not available)" cudnn_version = " (CuDNN not available)"
try: try:
cudnn_version = dnn.version() cudnn_version = dnn.version()
# 4100 should not print warning with cudnn 4 final. # 5100 should not print warning with cudnn 5 final.
if cudnn_version > 4100: if cudnn_version > 5100:
warn = ("Your CuDNN version is more recent than Theano." warn = ("Your CuDNN version is more recent than Theano."
" If you see problems, try updating Theano or" " If you see problems, try updating Theano or"
" downgrading CuDNN to version 4.") " downgrading CuDNN to version 5.")
cudnn_version = " (CuDNN version %s)" % cudnn_version cudnn_version = " (CuDNN version %s)" % cudnn_version
except Exception: except Exception:
pass cudnn_version = dnn.dnn_present.msg
print("Mapped name %s to device %s: %s%s" % ( print("Mapped name %s to device %s: %s%s" % (
name, dev, context.devname, cudnn_version), name, dev, context.devname, cudnn_version),
file=sys.stderr) file=sys.stderr)
......
...@@ -74,18 +74,15 @@ if ((err = cudnnCreate(&_handle)) != CUDNN_STATUS_SUCCESS) { ...@@ -74,18 +74,15 @@ if ((err = cudnnCreate(&_handle)) != CUDNN_STATUS_SUCCESS) {
try_run=False, output=True) try_run=False, output=True)
if not avail: if not avail:
return False, ("Theano cannot compile with cuDNN. " return False, ("cannot compile with CuDNN. "
"We got this error:\n" + str(err)) "We got this error:\n" + str(err))
return True, None return True, None
def _dnn_check_version(): def _dnn_check_version():
v = version() v = version()
if v < 3007: if v < 4007:
return False, ( return False, "Version too old. Update to v5."
"You have an old release of CuDNN (or a release candidate) "
"that isn't supported. Please update to at least v3 final "
"version.")
return True, None return True, None
...@@ -94,7 +91,7 @@ def dnn_present(): ...@@ -94,7 +91,7 @@ def dnn_present():
if dnn_present.avail is not None: if dnn_present.avail is not None:
return dnn_present.avail return dnn_present.avail
if config.dnn.enabled == "False": if config.dnn.enabled == "False":
dnn_present.msg = "disabled by dnn.enabled flag" dnn_present.msg = "Disabled by dnn.enabled flag"
dnn_present.avail = False dnn_present.avail = False
if pygpu is None: if pygpu is None:
...@@ -134,7 +131,7 @@ def dnn_available(context_name): ...@@ -134,7 +131,7 @@ def dnn_available(context_name):
# This is a hack because bin_id is in the from of # This is a hack because bin_id is in the from of
# "<something>_<major><minor>" for cuda devices. # "<something>_<major><minor>" for cuda devices.
if ctx.bin_id[-2:] < b'30': if ctx.bin_id[-2:] < b'30':
dnn_available.msg = "Device not supported by cuDNN" dnn_available.msg = "Device not supported"
return False return False
return True return True
...@@ -1620,7 +1617,7 @@ class NoCuDNNRaise(Optimizer): ...@@ -1620,7 +1617,7 @@ class NoCuDNNRaise(Optimizer):
# just skip this optimization. # just skip this optimization.
raise AssertionError( raise AssertionError(
"cuDNN optimization was enabled, but Theano was not able " "cuDNN optimization was enabled, but Theano was not able "
"to use it for context " + c + ". We got this error: \n" + "to use it for context " + str(c) + ". We got this error: \n" +
dnn_available.msg) dnn_available.msg)
gpu_seqopt.register("NoCuDNNRaise", NoCuDNNRaise(), 0, 'cudnn') gpu_seqopt.register("NoCuDNNRaise", NoCuDNNRaise(), 0, 'cudnn')
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论