Parse our options, create checkpoints directory suffix, and set up gpu device.
(self)
| 106 | opt_file.write('\n') |
| 107 | |
| 108 | def parse(self): |
| 109 | """Parse our options, create checkpoints directory suffix, and set up gpu device.""" |
| 110 | opt = self.gather_options() |
| 111 | opt.isTrain = self.isTrain # train or test |
| 112 | |
| 113 | # process opt.suffix |
| 114 | if opt.suffix: |
| 115 | suffix = ('_' + opt.suffix.format(**vars(opt))) if opt.suffix != '' else '' |
| 116 | opt.name = opt.name + suffix |
| 117 | |
| 118 | self.print_options(opt) |
| 119 | |
| 120 | # set gpu ids |
| 121 | str_ids = opt.gpu_ids.split(',') |
| 122 | opt.gpu_ids = [] |
| 123 | for str_id in str_ids: |
| 124 | id = int(str_id) |
| 125 | if id >= 0: |
| 126 | opt.gpu_ids.append(id) |
| 127 | if len(opt.gpu_ids) > 0: |
| 128 | torch.cuda.set_device(opt.gpu_ids[0]) |
| 129 | |
| 130 | self.opt = opt |
| 131 | return self.opt |
no test coverage detected