50c88091cbb82591db49f5328de8069d6d464bc7,base/base_trainer.py,BaseTrainer,__init__,#BaseTrainer#Any#Any#Any#Any#Any#Any#Any#,15

Before Change


        if config["cuda"] and not torch.cuda.is_available():
            self.logger.warning("Warning: There\"s no GPU available on this machine, "
                                "training will be performed on CPU.")
        self.device = torch.device("cuda:" + str(config["gpu"]) if self.with_cuda else "cpu")
        self.model = model.to(self.device)

        self.loss = loss

After Change


            n_gpu_use = 0
        if n_gpu_use > n_gpu:
            msg = "Warning: The number of GPU\"s configured to use is {}, but only {} are available on this machine.".format(n_gpu_use, n_gpu)
            self.logger.warning(msg)
            n_gpu_use = n_gpu
        self.device = torch.device("cuda:0" if n_gpu_use > 0 else "cpu")
        self.model = model.to(self.device)
        if n_gpu_use > 1:
            self.model = torch.nn.DataParallel(model, device_ids=list(range(n_gpu_use)))

        self.loss = loss
        self.metrics = metrics
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: victoresque/pytorch-template
Commit Name: 50c88091cbb82591db49f5328de8069d6d464bc7
Time: 2018-10-02
Author: sunq0313@gmail.com
File Name: base/base_trainer.py
Class Name: BaseTrainer
Method Name: __init__


Project Name: ray-project/ray
Commit Name: 5e76a51d56f9383d28264810a6f4db7ba12998fe
Time: 2021-02-23
Author: fyrestone@outlook.com
File Name: dashboard/head.py
Class Name: DashboardHead
Method Name: run


Project Name: deepgram/kur
Commit Name: b2f7c23957129e377e938f050a8534453969c330
Time: 2017-03-21
Author: ajsyp@syptech.net
File Name: kur/backend/keras_backend.py
Class Name: KerasBackend
Method Name: __init__