diff --git a/src/engine/threaded_engine.h b/src/engine/threaded_engine.h index ab06ca1b9b47..640eac4de086 100644 --- a/src/engine/threaded_engine.h +++ b/src/engine/threaded_engine.h @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -306,6 +307,8 @@ class ThreadedEngine : public Engine { objpool_varblk_ref_ = common::ObjectPool::_GetSharedRef(); objpool_var_ref_ = common::ObjectPool::_GetSharedRef(); + storage_ref_ = Storage::_GetSharedRef(); + // Get a ref to the profiler so that it doesn't get killed before us profiler::Profiler::Get(&profiler_); } @@ -549,6 +552,12 @@ class ThreadedEngine : public Engine { std::shared_ptr > objpool_varblk_ref_; std::shared_ptr > objpool_var_ref_; + /*! + * \brief Async destruction of some objects is relied on storage, + * prevent it from being destructed too early + */ + std::shared_ptr storage_ref_; + #if MXNET_USE_CUDA /*! \brief Number of GPU devices available */ std::atomic device_count_{-1}; diff --git a/tests/python/gpu/test_operator_gpu.py b/tests/python/gpu/test_operator_gpu.py index 7d7c2ed71216..c12c94b41f5c 100644 --- a/tests/python/gpu/test_operator_gpu.py +++ b/tests/python/gpu/test_operator_gpu.py @@ -547,18 +547,8 @@ def _conv_with_num_streams(seed): @with_seed() def test_convolution_multiple_streams(): - engines = ['NaiveEngine', 'ThreadedEngine', 'ThreadedEnginePerDevice'] - - if os.getenv('MXNET_ENGINE_TYPE') is not None: - engines = [os.getenv('MXNET_ENGINE_TYPE'),] - print("Only running against '%s'" % engines[0], file=sys.stderr, end='') - # Remove this else clause when the ThreadedEngine can handle this test - else: - engines.remove('ThreadedEngine') - print("SKIP: 'ThreadedEngine', only running against %s" % engines, file=sys.stderr, end='') - for num_streams in [1, 2]: - for engine in engines: + for engine in ['NaiveEngine', 'ThreadedEngine', 'ThreadedEnginePerDevice']: print("Starting engine %s with %d streams." % (engine, num_streams), file=sys.stderr) run_in_spawned_process(_conv_with_num_streams, {'MXNET_GPU_WORKER_NSTREAMS' : num_streams, 'MXNET_ENGINE_TYPE' : engine})