提交 da995a27 authored 作者: Frederic's avatar Frederic

Raise an error in ProfileMode if CUDA is enable and we CUDA_LAUNCH_BLOCKING isn't set to 1.

上级 c24b0ffa
import atexit import atexit
import copy import copy
import os
import time import time
import theano
from theano.gof.link import WrapLinker from theano.gof.link import WrapLinker
from theano.compile.mode import (Mode, register_mode, from theano.compile.mode import (Mode, register_mode,
predefined_modes, predefined_linkers, predefined_modes, predefined_linkers,
...@@ -42,6 +44,18 @@ class Profile_Maker(FunctionMaker): ...@@ -42,6 +44,18 @@ class Profile_Maker(FunctionMaker):
def create(self, input_storage=None, trustme=False): def create(self, input_storage=None, trustme=False):
ret = super(Profile_Maker, self).create(input_storage, trustme) ret = super(Profile_Maker, self).create(input_storage, trustme)
if (hasattr(theano, 'sandbox') and
hasattr(theano.sandbox, 'cuda') and
theano.sandbox.cuda.cuda_enabled):
if os.environ.get('CUDA_LAUNCH_BLOCKING', '0') != '1':
raise Exception(
"You are running Theano profiler with CUDA enabled."
" Theano GPU ops execution are asynchron by default."
" So by default, the profile is useless."
" You must use set the environment variable"
" CUDA_LAUNCH_BLOCKING to 1 to tell the CUDA drvier to"
" synchonize the execution to get meaning full profile.")
# create a function-specific storage container for profiling info # create a function-specific storage container for profiling info
profile = ProfileStats(atexit_print=False) profile = ProfileStats(atexit_print=False)
self.mode.profile_stats[ret] = profile self.mode.profile_stats[ret] = profile
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论