Commit 5c9174db authored by Yuxin Wu's avatar Yuxin Wu

fix build

parent 5fc3a2b1
...@@ -14,6 +14,7 @@ from tensorflow.python.client import timeline ...@@ -14,6 +14,7 @@ from tensorflow.python.client import timeline
from .base import Callback from .base import Callback
from ..utils import logger from ..utils import logger
from ..utils.concurrency import ensure_proc_terminate, subproc_call from ..utils.concurrency import ensure_proc_terminate, subproc_call
from ..utils.gpu import get_nr_gpu
__all__ = ['GPUUtilizationTracker', 'GraphProfiler'] __all__ = ['GPUUtilizationTracker', 'GraphProfiler']
...@@ -33,8 +34,12 @@ class GPUUtilizationTracker(Callback): ...@@ -33,8 +34,12 @@ class GPUUtilizationTracker(Callback):
""" """
if devices is None: if devices is None:
env = os.environ.get('CUDA_VISIBLE_DEVICES') env = os.environ.get('CUDA_VISIBLE_DEVICES')
assert env is not None, "[GPUUtilizationTracker] Both devices and CUDA_VISIBLE_DEVICES are None!" if env is None:
self._devices = env.split(',') logger.warn("[GPUUtilizationTracker] Both devices and CUDA_VISIBLE_DEVICES are None! "
"Will monitor all visible GPUs!")
self._devices = list(range(get_nr_gpu()))
else:
self._devices = env.split(',')
else: else:
self._devices = list(map(str, devices)) self._devices = list(map(str, devices))
assert len(self._devices), "[GPUUtilizationTracker] No GPU device given!" assert len(self._devices), "[GPUUtilizationTracker] No GPU device given!"
......
...@@ -29,6 +29,8 @@ def MaxPooling(x, shape, stride=None, padding='VALID', data_format='NHWC'): ...@@ -29,6 +29,8 @@ def MaxPooling(x, shape, stride=None, padding='VALID', data_format='NHWC'):
Returns: Returns:
tf.Tensor named ``output``. tf.Tensor named ``output``.
""" """
if stride is None:
stride = shape
ret = tf.layers.max_pooling2d(x, shape, stride, padding, ret = tf.layers.max_pooling2d(x, shape, stride, padding,
'channels_last' if data_format == 'NHWC' else 'channels_first') 'channels_last' if data_format == 'NHWC' else 'channels_first')
return tf.identity(ret, name='output') return tf.identity(ret, name='output')
...@@ -48,6 +50,8 @@ def AvgPooling(x, shape, stride=None, padding='VALID', data_format='NHWC'): ...@@ -48,6 +50,8 @@ def AvgPooling(x, shape, stride=None, padding='VALID', data_format='NHWC'):
Returns: Returns:
tf.Tensor named ``output``. tf.Tensor named ``output``.
""" """
if stride is None:
stride = shape
ret = tf.layers.average_pooling2d(x, shape, stride, padding, ret = tf.layers.average_pooling2d(x, shape, stride, padding,
'channels_last' if data_format == 'NHWC' else 'channels_first') 'channels_last' if data_format == 'NHWC' else 'channels_first')
return tf.identity(ret, name='output') return tf.identity(ret, name='output')
......
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