From dev-return-4861-archive-asf-public=cust-asf.ponee.io@singa.apache.org Sun Apr 5 00:05:15 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 002EB180660 for ; Sun, 5 Apr 2020 02:05:14 +0200 (CEST) Received: (qmail 93287 invoked by uid 500); 5 Apr 2020 00:05:14 -0000 Mailing-List: contact dev-help@singa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@singa.apache.org Delivered-To: mailing list dev@singa.apache.org Received: (qmail 93277 invoked by uid 99); 5 Apr 2020 00:05:14 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Apr 2020 00:05:14 +0000 From: GitBox To: dev@singa.apache.org Subject: [GitHub] [singa] chrishkchris edited a comment on issue #651: [WIP ]Simply example APIs Message-ID: <158604511425.11654.17244636126675404230.gitbox@gitbox.apache.org> References: In-Reply-To: Date: Sun, 05 Apr 2020 00:05:14 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit chrishkchris edited a comment on issue #651: [WIP ]Simply example APIs URL: https://github.com/apache/singa/pull/651#issuecomment-609049842 > I suggest to merge the examples under `examples/autograd` into the follow structure. > > ``` > autograd > train.py > train_mpi.py > train_multiprocess.py > data # define the data loading and preprocessing > cifar10.py > mnist.py > model # define the model > cnn.py > resnet.py > xception.py > ``` > > The pseudo code of each file: > > ```python > # train.py > def run(max_epoch, worker_id, num_workers, model, data, sgd): > if model == 'resnet': > from model import resnet > model = resnet.create_model() > elif model == 'cnn': > model = cnn.create_model() > .... > if data == 'cifar10': > from data import cifar10: > train_x, train_y, val_x, val_y = cifar10.load() > elif data == 'mnist': > .... > > train_x, train_y, val_x, val_y = partition(worker_id, num_workers, train_x, train_y, val_x, val_y) > > # bp and sgd > > if __name__ == '__main__': > # use argparse to get command config: max_epoch, model, data, etc. for single gpu training > sgd = # create sgd > run(0, 1, ..., sgd) > > # train_mpi.py > if __name__ == '__main__': > # use argparse to get command args: max_epoch, model, data, etc. for multi-gpu training > sgd = # create sgd > dist_sgd = DistOpt(sgd...) > run(dist_sgd.rank, dist_sgd.world_size, ... dist_sgd) > > # train_multiprocess.py > def run(rank, num_gpu, ...): > sgd = ... > dist_sgd = DistOpt(sgd) > train.run(rank, num_gpu, ... dist_sgd) > > if __name__ == '__main__': > # use argparse to get command args: max_epoch, model, data, etc. for multi-gpu training > nccl_id = ... > process = [] > for worker_id in range(0, gpu_per_node): > process.append(multiprocessing.Process(target=run, args=(worker_id, ... nccl_id))) > > for p in process: > p.start() > ``` thanks! I am working on it. There may be three issues that need to think about: (i) maybe difficult to include graph module (please see resnet_module.py to see the different between layer model and module model). In this case, we may consider retain resnet_module.py, cnn_module.py, mlp_module.py indpendently, or to make another run.py function specially for graph. (ii) don't know how to show this example in the doc dist-train.md. So maybe in the doc we can still use doc_dist_train.py for examples ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services