提交 9e961a73 authored 作者: Frederic Bastien's avatar Frederic Bastien

If the user do theano.function(profile=True), do a warning about…

If the user do theano.function(profile=True), do a warning about CUDA_LAUNCH_BLOCKING not being used.
上级 cfd45e24
...@@ -18,6 +18,7 @@ import sys ...@@ -18,6 +18,7 @@ import sys
import time import time
from collections import defaultdict from collections import defaultdict
from six import iteritems from six import iteritems
import warnings
import numpy as np import numpy as np
...@@ -253,20 +254,25 @@ class ProfileStats(object): ...@@ -253,20 +254,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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论