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

Merge pull request #5132 from nouiz/gpu_profile

warn when profiling.ignore_first_call isn't used.
......@@ -9,6 +9,8 @@ ProfileStats object for runtime and memory profiling.
#
from __future__ import absolute_import, print_function, division
import logging
__authors__ = "James Bergstra"
__reviewer__ = "Razvan Pascanu"
__copyright__ = "(c) 2011, Universite de Montreal"
......@@ -31,6 +33,8 @@ import theano
from six import iteritems
from theano.gof import graph
logger = logging.getLogger('theano.compile.profiling')
theano_imported_time = time.time()
config = theano.config
......@@ -210,9 +214,12 @@ class ProfileStats(object):
# param is called flag_time_thunks because most other attributes with time
# in the name are times *of* something, rather than configuration flags.
def __init__(self, atexit_print=True, flag_time_thunks=None, **kwargs):
if (hasattr(theano, 'sandbox') and
hasattr(theano.sandbox, 'cuda') and
theano.sandbox.cuda.cuda_enabled):
if (config.profile and
((hasattr(theano, 'sandbox') and
hasattr(theano.sandbox, 'cuda') and
theano.sandbox.cuda.cuda_enabled) or (
hasattr(theano, 'gpuarray') and
theano.gpuarray.pygpu_activated))):
if os.environ.get('CUDA_LAUNCH_BLOCKING', '0') != '1':
raise Exception(
"You are running the Theano profiler with CUDA enabled."
......@@ -221,6 +228,14 @@ class ProfileStats(object):
" You must set the environment variable"
" CUDA_LAUNCH_BLOCKING to 1 to tell the CUDA driver to"
" synchronize the execution to get a meaningful profile.")
if (config.profile and
hasattr(theano, 'gpuarray') and
theano.gpuarray.pygpu_activated and
not config.profiling.ignore_first_call):
logger.warn(
"Theano flag profiling.ignore_first_call is False."
" This cause bad profiling result in the new gpu"
" back-end, we as sometimes we compile at the first call.")
self.apply_callcount = {}
self.output_size = {}
......
......@@ -752,9 +752,11 @@ class VM_Linker(link.LocalLinker):
"""
if (config.profile and
hasattr(theano, 'sandbox') and
hasattr(theano.sandbox, 'cuda') and
theano.sandbox.cuda.cuda_enabled):
((hasattr(theano, 'sandbox') and
hasattr(theano.sandbox, 'cuda') and
theano.sandbox.cuda.cuda_enabled) or
(hasattr(theano, 'gpuarray') and
theano.gpuarray.pygpu_activated))):
if os.environ.get('CUDA_LAUNCH_BLOCKING', '0') != '1':
raise Exception(
"You are running the Theano profiler with CUDA enabled."
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论