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