提交 4e482807 authored 作者: Frédéric Bastien's avatar Frédéric Bastien 提交者: GitHub

Merge pull request #5686 from nouiz/warnings

If the user do theano.function(profile=True), do a warning about CUDA…
...@@ -261,20 +261,25 @@ class ProfileStats(object): ...@@ -261,20 +261,25 @@ class ProfileStats(object):
# in the name are times *of* something, rather than configuration flags. # in the name are times *of* something, rather than configuration flags.
def __init__(self, atexit_print=True, flag_time_thunks=None, def __init__(self, atexit_print=True, flag_time_thunks=None,
gpu_checks=True, **kwargs): gpu_checks=True, **kwargs):
if (config.profile and gpu_checks and if (gpu_checks and
((hasattr(theano, 'sandbox') and ((hasattr(theano, 'sandbox') and
hasattr(theano.sandbox, 'cuda') and hasattr(theano.sandbox, 'cuda') and
theano.sandbox.cuda.cuda_enabled) or ( theano.sandbox.cuda.cuda_enabled) or (
hasattr(theano, 'gpuarray') and hasattr(theano, 'gpuarray') and
theano.gpuarray.pygpu_activated))): theano.gpuarray.pygpu_activated)) and
if os.environ.get('CUDA_LAUNCH_BLOCKING', '0') != '1': os.environ.get('CUDA_LAUNCH_BLOCKING', '0') != '1'):
raise Exception( msg = (
"You are running the Theano profiler with CUDA enabled." "You are running the Theano profiler with CUDA enabled."
" Theano GPU ops execution is asynchronous by default." " Theano GPU ops execution is asynchronous by default."
" So by default, the profile is useless." " So by default, the profile is useless."
" You must set the environment variable" " You must set the environment variable"
" CUDA_LAUNCH_BLOCKING to 1 to tell the CUDA driver to" " CUDA_LAUNCH_BLOCKING to 1 to tell the CUDA driver to"
" synchronize the execution to get a meaningful profile.") " synchronize the execution to get a meaningful profile.")
if config.profile:
raise Exception(msg)
else:
warnings.warn(msg)
if (config.profile and gpu_checks and if (config.profile and gpu_checks and
hasattr(theano, 'gpuarray') and hasattr(theano, 'gpuarray') and
theano.gpuarray.pygpu_activated and theano.gpuarray.pygpu_activated and
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论