Commit 51056e19 by Ting PAN

Fix the crash when terminating processes

1 parent 77179032
...@@ -268,7 +268,7 @@ def FeedTensor(tensor, ndarray, force_cpu=False, dtype=None): ...@@ -268,7 +268,7 @@ def FeedTensor(tensor, ndarray, force_cpu=False, dtype=None):
raise TypeError('The preset data type is {}, but force to {}.'. raise TypeError('The preset data type is {}, but force to {}.'.
format(preset_dtype, dtype)) format(preset_dtype, dtype))
auto_dtype = preset_dtype auto_dtype = preset_dtype
ndarray = np.array(ndarray, dtype=auto_dtype) ndarray = np.array(ndarray, dtype=auto_dtype, copy=False)
FeedTensorCC(name, ndarray, _stringify_proto(dev)) FeedTensorCC(name, ndarray, _stringify_proto(dev))
......
...@@ -137,6 +137,7 @@ List Brief ...@@ -137,6 +137,7 @@ List Brief
`Tile`_ Tile the input according to the given multiples. `Tile`_ Tile the input according to the given multiples.
`Pad`_ Pad the input according to the given paddings. `Pad`_ Pad the input according to the given paddings.
`Crop`_ Crop the input according to the given starts and ends. `Crop`_ Crop the input according to the given starts and ends.
`OneHot`_ Generate the one-hot representation of inputs.
`Flatten`_ Flatten the input along the given axes. `Flatten`_ Flatten the input along the given axes.
`Reshape`_ Reshape the dimensions of input. `Reshape`_ Reshape the dimensions of input.
`ExpandDims`_ ExpandDims interface of NDArray. `ExpandDims`_ ExpandDims interface of NDArray.
...@@ -263,6 +264,7 @@ List Brief ...@@ -263,6 +264,7 @@ List Brief
.. _Repeat: operators/ndarray.html#dragon.operators.ndarray.Repeat .. _Repeat: operators/ndarray.html#dragon.operators.ndarray.Repeat
.. _Tile: operators/ndarray.html#dragon.operators.ndarray.Tile .. _Tile: operators/ndarray.html#dragon.operators.ndarray.Tile
.. _Pad: operators/ndarray.html#dragon.operators.ndarray.Pad .. _Pad: operators/ndarray.html#dragon.operators.ndarray.Pad
.. _OneHot: operators/ndarray.html#dragon.operators.ndarray.OneHot
.. _Flatten: operators/ndarray.html#dragon.operators.ndarray.Flatten .. _Flatten: operators/ndarray.html#dragon.operators.ndarray.Flatten
.. _Reshape: operators/ndarray.html#dragon.operators.ndarray.Reshape .. _Reshape: operators/ndarray.html#dragon.operators.ndarray.Reshape
.. _ExpandDims: operators/ndarray.html#dragon.operators.ndarray.ExpandDims .. _ExpandDims: operators/ndarray.html#dragon.operators.ndarray.ExpandDims
......
...@@ -37,14 +37,6 @@ class BlobFetcher(Process): ...@@ -37,14 +37,6 @@ class BlobFetcher(Process):
self.Q_in = self.Q_out = None self.Q_in = self.Q_out = None
self.daemon = True self.daemon = True
def cleanup():
from dragon.config import logger
logger.info('Terminating BlobFetcher......')
self.terminate()
self.join()
import atexit
atexit.register(cleanup)
def im_list_to_blob(self): def im_list_to_blob(self):
"""Get image and label blobs. """Get image and label blobs.
......
...@@ -155,6 +155,21 @@ class DataBatch(object): ...@@ -155,6 +155,21 @@ class DataBatch(object):
self.echo() self.echo()
def cleanup():
def terminate(processes):
for process in processes:
process.terminate()
process.join()
from dragon.config import logger
logger.info('Terminating BlobFetcher ......')
terminate(self._fetchers)
logger.info('Terminating DataTransformer ......')
terminate(self._transformers)
logger.info('Terminating DataReader......')
terminate(self._readers)
import atexit
atexit.register(cleanup)
def get(self): def get(self):
"""Get a batch. """Get a batch.
......
...@@ -53,14 +53,6 @@ class DataReader(Process): ...@@ -53,14 +53,6 @@ class DataReader(Process):
self.Q_out = None self.Q_out = None
self.daemon = True self.daemon = True
def cleanup():
from dragon.config import logger
logger.info('Terminating DataReader......')
self.terminate()
self.join()
import atexit
atexit.register(cleanup)
def element(self): def element(self):
"""Get the value of current record. """Get the value of current record.
......
...@@ -70,14 +70,6 @@ class DataTransformer(Process): ...@@ -70,14 +70,6 @@ class DataTransformer(Process):
self.Q_in = self.Q_out = None self.Q_in = self.Q_out = None
self.daemon = True self.daemon = True
def cleanup():
from dragon.config import logger
logger.info('Terminating DataTransformer......')
self.terminate()
self.join()
import atexit
atexit.register(cleanup)
def transform_image_labels(self, serialized): def transform_image_labels(self, serialized):
"""Get image and labels from a serialized str. """Get image and labels from a serialized str.
......
...@@ -36,7 +36,7 @@ find_packages('dragon') ...@@ -36,7 +36,7 @@ find_packages('dragon')
find_modules() find_modules()
setup(name = 'dragon', setup(name = 'dragon',
version='0.2.1.1', version='0.2.1.2',
description = 'Dragon: A Computation Graph Virtual Machine Based Deep Learning Framework', description = 'Dragon: A Computation Graph Virtual Machine Based Deep Learning Framework',
url='https://github.com/neopenx/Dragon', url='https://github.com/neopenx/Dragon',
author='Ting Pan', author='Ting Pan',
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!