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,
return signature, return_annotation
def autodoc_skip_member(app, what, name, obj, skip, options):
for deprecate in [
if name in [
'DistributedReplicatedTrainer',
'SingleCostFeedfreeTrainer',
'SimpleFeedfreeTrainer',
......@@ -360,8 +360,7 @@ def autodoc_skip_member(app, what, name, obj, skip, options):
'remap_get_variable',
'freeze_get_variable',
'ParamRestore']:
if deprecate in name:
return True
return True
if name in ['get_data', 'size', 'reset_state']:
# skip these methods with empty docstring
if not obj.__doc__ and inspect.isfunction(obj):
......
......@@ -14,7 +14,7 @@ A High Level Glance
* 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.
: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.
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):
"""
assert isinstance(ds, DataFlow), ds
self.ds = ds
# TODO avoid infinite repeat, to allow accurate size handling
self._repeat_ds = RepeatedData(self.ds, -1)
def _size(self):
......
......@@ -49,9 +49,8 @@ class InputSource(object):
def reset_state(self):
"""
Semantics of this method has not been well defined.
Reinitialize this InputSource.
"""
# TODO
self._reset_state()
def _reset_state(self):
......
import os
from .utils import logger
# issue#7378 may happen with custom opencv. It doesn't hurt to disable opencl
os.environ['OPENCV_OPENCL_RUNTIME'] = ''
try:
# issue#1924 may happen on old systems
import cv2 # noqa
if int(cv2.__version__.split('.')[0]) == 3:
cv2.ocl.setUseOpenCL(False)
except ImportError:
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_AUTOTUNE_THRESHOLD'] = '3' # use more warm-up
......
......@@ -33,14 +33,13 @@ class Trainer(object):
Attributes:
config (TrainConfig): the config used in this trainer.
model (ModelDesc)
model (ModelDesc):
sess (tf.Session): the current session in use.
hooked_sess (tf.MonitoredSession): the session with hooks.
monitors (Monitors): the monitors. Callbacks can use it for logging.
epoch_num (int): the number of epochs that have finished.
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?
......@@ -174,6 +173,9 @@ class Trainer(object):
@property
def global_step(self):
"""
The number of steps that have finished or is currently running.
"""
try:
return self._starting_step + \
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