From 30d57a0872da8c95a958fb563ac56d4b25cc2eea Mon Sep 17 00:00:00 2001 From: reminisce Date: Tue, 15 Aug 2017 20:22:44 -0700 Subject: [PATCH 1/3] Add waitall() --- benchmark/python/sparse_end2end.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/benchmark/python/sparse_end2end.py b/benchmark/python/sparse_end2end.py index 62a3b77b8482..147e55108a02 100644 --- a/benchmark/python/sparse_end2end.py +++ b/benchmark/python/sparse_end2end.py @@ -176,6 +176,7 @@ def row_sparse_pull(kv, key, data, slices, weight_array, priority): # weight_array bound to executors of the contexts weight_array = mod._exec_group.param_arrays[index] + mx.nd.waitall() # sync point for initialization # start profiler if profiler: device = 'cpu' @@ -215,7 +216,12 @@ def row_sparse_pull(kv, key, data, slices, weight_array, priority): except StopIteration: end_of_batch = True # accumulate prediction accuracy - mod.update_metric(metric, batch.label) + # comment out metrics update to eliminate asnumpy call + # use waitall() to replace metrics update as sync point + # mod.update_metric(metric, batch.label) + # TODO(junwu): Remove the following line and use update_metric + # after improving its performance + mx.nd.waitall() # sync point for the current minibatch logging.info('epoch %d, %s' % (epoch, metric.get())) if epoch == 0: print "num_batches = ", nbatch From 912e927925984af789b8147b73b0778964f454c1 Mon Sep 17 00:00:00 2001 From: reminisce Date: Tue, 15 Aug 2017 22:05:05 -0700 Subject: [PATCH 2/3] Add dummy metric option --- benchmark/python/sparse_end2end.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/benchmark/python/sparse_end2end.py b/benchmark/python/sparse_end2end.py index 147e55108a02..8df64e3e7d0e 100644 --- a/benchmark/python/sparse_end2end.py +++ b/benchmark/python/sparse_end2end.py @@ -27,6 +27,8 @@ 'otherwise, use gpu(0),...,gpu(num_gpu-1)') parser.add_argument('--output-dim', type=int, default=4, help='number of columns of the forward output') +parser.add_argument('--dummy-metric', type=int, default=0, + help='whether to call update_metric') def get_libsvm_data(data_dir, data_name, url, data_origin_name): @@ -216,12 +218,10 @@ def row_sparse_pull(kv, key, data, slices, weight_array, priority): except StopIteration: end_of_batch = True # accumulate prediction accuracy - # comment out metrics update to eliminate asnumpy call - # use waitall() to replace metrics update as sync point - # mod.update_metric(metric, batch.label) - # TODO(junwu): Remove the following line and use update_metric - # after improving its performance - mx.nd.waitall() # sync point for the current minibatch + if args.dummy_metric == 0: + mod.update_metric(metric, batch.label) + else: # call waitall to replace update_metric as sync point + mx.nd.waitall() # sync point for the current minibatch logging.info('epoch %d, %s' % (epoch, metric.get())) if epoch == 0: print "num_batches = ", nbatch From 7cb94eb4ac729a72333d4e2624a1fee4a64951a8 Mon Sep 17 00:00:00 2001 From: reminisce Date: Wed, 16 Aug 2017 10:37:30 -0700 Subject: [PATCH 3/3] Add header license --- benchmark/python/sparse_end2end.py | 17 +++++++++++++++++ tests/python/gpu/test_kvstore_gpu.py | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/benchmark/python/sparse_end2end.py b/benchmark/python/sparse_end2end.py index 8df64e3e7d0e..e9d8bf884713 100644 --- a/benchmark/python/sparse_end2end.py +++ b/benchmark/python/sparse_end2end.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + from mxnet.test_utils import * import time import argparse diff --git a/tests/python/gpu/test_kvstore_gpu.py b/tests/python/gpu/test_kvstore_gpu.py index 6d3ba989a84f..ffc0cc1f93e0 100644 --- a/tests/python/gpu/test_kvstore_gpu.py +++ b/tests/python/gpu/test_kvstore_gpu.py @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # pylint: skip-file import mxnet as mx import numpy as np