提交 a9cb097c authored 作者: Josh Bleecher Snyder's avatar Josh Bleecher Snyder

prevent NameError when a prior error (unusual) caused variable not to be defined

上级 e68b5055
...@@ -156,10 +156,12 @@ def use(device, force=False, default_to_move_computation_to_gpu = True, ...@@ -156,10 +156,12 @@ def use(device, force=False, default_to_move_computation_to_gpu = True,
raise EnvironmentError("You forced use of device %s, but CUDA initialization failed " raise EnvironmentError("You forced use of device %s, but CUDA initialization failed "
"with error:\n%s" % (device, cuda_initialization_error_message)) "with error:\n%s" % (device, cuda_initialization_error_message))
if not cuda_available: if not cuda_available:
error_addendum = ""
try:
if cuda_initialization_error_message: if cuda_initialization_error_message:
error_addendum = " (error: %s)" % cuda_initialization_error_message error_addendum = " (error: %s)" % cuda_initialization_error_message
else: except NameError: # cuda_initialization_error_message is not available b/c compilation failed
error_addendum = "" pass
warning('CUDA is installed, but device %s is not available%s' % (device, error_addendum)) warning('CUDA is installed, but device %s is not available%s' % (device, error_addendum))
return return
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论