Commit 7ae014f1 authored by Yuxin Wu's avatar Yuxin Wu

check cv2 cuda support during import

parent 1bf2737f
...@@ -350,7 +350,7 @@ def process_signature(app, what, name, obj, options, signature, ...@@ -350,7 +350,7 @@ def process_signature(app, what, name, obj, options, signature,
return signature, return_annotation return signature, return_annotation
def autodoc_skip_member(app, what, name, obj, skip, options): def autodoc_skip_member(app, what, name, obj, skip, options):
for deprecate in [ if name in [
'DistributedReplicatedTrainer', 'DistributedReplicatedTrainer',
'SingleCostFeedfreeTrainer', 'SingleCostFeedfreeTrainer',
'SimpleFeedfreeTrainer', 'SimpleFeedfreeTrainer',
...@@ -360,8 +360,7 @@ def autodoc_skip_member(app, what, name, obj, skip, options): ...@@ -360,8 +360,7 @@ def autodoc_skip_member(app, what, name, obj, skip, options):
'remap_get_variable', 'remap_get_variable',
'freeze_get_variable', 'freeze_get_variable',
'ParamRestore']: 'ParamRestore']:
if deprecate in name: return True
return True
if name in ['get_data', 'size', 'reset_state']: if name in ['get_data', 'size', 'reset_state']:
# skip these methods with empty docstring # skip these methods with empty docstring
if not obj.__doc__ and inspect.isfunction(obj): if not obj.__doc__ and inspect.isfunction(obj):
......
...@@ -14,7 +14,7 @@ A High Level Glance ...@@ -14,7 +14,7 @@ A High Level Glance
* You can use any TF-based symbolic function library to define a model in tensorpack. * You can use any TF-based symbolic function library to define a model in tensorpack.
And ``ModelDesc`` is an interface to connect symbolic graph to tensorpack trainers. And ``ModelDesc`` is an interface to connect symbolic graph to tensorpack trainers.
:doc:`model` introduces where and how you define the graph for tensorpack trainers to use, :doc:`graph` and :doc:`symbolic` introduces where and how you define the graph for tensorpack trainers to use,
and how you can benefit from the small symbolic function library in tensorpack. and how you can benefit from the small symbolic function library in tensorpack.
Both DataFlow and models can be used outside tensorpack, as just a data processing library and a symbolic Both DataFlow and models can be used outside tensorpack, as just a data processing library and a symbolic
......
...@@ -72,6 +72,7 @@ class FeedInput(InputSource): ...@@ -72,6 +72,7 @@ class FeedInput(InputSource):
""" """
assert isinstance(ds, DataFlow), ds assert isinstance(ds, DataFlow), ds
self.ds = ds self.ds = ds
# TODO avoid infinite repeat, to allow accurate size handling
self._repeat_ds = RepeatedData(self.ds, -1) self._repeat_ds = RepeatedData(self.ds, -1)
def _size(self): def _size(self):
......
...@@ -49,9 +49,8 @@ class InputSource(object): ...@@ -49,9 +49,8 @@ class InputSource(object):
def reset_state(self): def reset_state(self):
""" """
Semantics of this method has not been well defined. Reinitialize this InputSource.
""" """
# TODO
self._reset_state() self._reset_state()
def _reset_state(self): def _reset_state(self):
......
import os import os
from .utils import logger
# issue#7378 may happen with custom opencv. It doesn't hurt to disable opencl # issue#7378 may happen with custom opencv. It doesn't hurt to disable opencl
os.environ['OPENCV_OPENCL_RUNTIME'] = '' os.environ['OPENCV_OPENCL_RUNTIME'] = ''
try: try:
# issue#1924 may happen on old systems # issue#1924 may happen on old systems
import cv2 # noqa import cv2 # noqa
if int(cv2.__version__.split('.')[0]) == 3:
cv2.ocl.setUseOpenCL(False)
except ImportError: except ImportError:
pass pass
else:
if int(cv2.__version__.split('.')[0]) == 3:
cv2.ocl.setUseOpenCL(False)
# check if cv is built with cuda
info = cv2.getBuildInformation().split('\n')
for line in info:
if 'use cuda' in line.lower():
answer = line.split()[-1].lower()
if answer == 'yes':
# issue#1197
logger.warn("OpenCV is built with CUDA support. "
"This may cause slow initialization or sometimes segfault with TensorFlow.")
break
os.environ['TF_ENABLE_WINOGRAD_NONFUSED'] = '1' # issue#9339 os.environ['TF_ENABLE_WINOGRAD_NONFUSED'] = '1' # issue#9339
os.environ['TF_AUTOTUNE_THRESHOLD'] = '3' # use more warm-up os.environ['TF_AUTOTUNE_THRESHOLD'] = '3' # use more warm-up
......
...@@ -33,14 +33,13 @@ class Trainer(object): ...@@ -33,14 +33,13 @@ class Trainer(object):
Attributes: Attributes:
config (TrainConfig): the config used in this trainer. config (TrainConfig): the config used in this trainer.
model (ModelDesc) model (ModelDesc):
sess (tf.Session): the current session in use. sess (tf.Session): the current session in use.
hooked_sess (tf.MonitoredSession): the session with hooks. hooked_sess (tf.MonitoredSession): the session with hooks.
monitors (Monitors): the monitors. Callbacks can use it for logging. monitors (Monitors): the monitors. Callbacks can use it for logging.
epoch_num (int): the number of epochs that have finished. epoch_num (int): the number of epochs that have finished.
local_step (int): the number of steps that have finished in the current epoch. local_step (int): the number of steps that have finished in the current epoch.
global_step (int): the number of steps that have finished or is currently running.
""" """
# step attr only available after before_train? # step attr only available after before_train?
...@@ -174,6 +173,9 @@ class Trainer(object): ...@@ -174,6 +173,9 @@ class Trainer(object):
@property @property
def global_step(self): def global_step(self):
"""
The number of steps that have finished or is currently running.
"""
try: try:
return self._starting_step + \ return self._starting_step + \
self.config.steps_per_epoch * (self.epoch_num - 1) + \ self.config.steps_per_epoch * (self.epoch_num - 1) + \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment