import torch log.info({ 'torch': torch.__version__, 'available': torch.cuda.is_available() }) current_device = torch.cuda.current_device() mem_free, mem_total = torch.cuda.mem_get_info() log.info({ 'cuda': torch.version.cuda, 'available': torch.cuda.is_available(), 'arch': torch
()
| 171 | |
| 172 | |
| 173 | async def init(): |
| 174 | ''' |
| 175 | import torch |
| 176 | log.info({ 'torch': torch.__version__, 'available': torch.cuda.is_available() }) |
| 177 | current_device = torch.cuda.current_device() |
| 178 | mem_free, mem_total = torch.cuda.mem_get_info() |
| 179 | log.info({ 'cuda': torch.version.cuda, 'available': torch.cuda.is_available(), 'arch': torch.cuda.get_arch_list(), 'device': torch.cuda.get_device_name(current_device), 'memory': { 'free': round(mem_free / 1024 / 1024), 'total': (mem_total / 1024 / 1024) } }) |
| 180 | ''' |
| 181 | options = Map({}) |
| 182 | options.flags = await get('/sdapi/v1/cmd-flags') |
| 183 | log.debug({ 'flags': options.flags }) |
| 184 | data = await get('/sdapi/v1/sd-models') |
| 185 | options.models = [obj['title'] for obj in data] |
| 186 | log.debug({ 'registered models': options.models }) |
| 187 | found = sd.options.sd_model_checkpoint if sd.options.sd_model_checkpoint in options.models else None |
| 188 | if found is None: |
| 189 | found = [i for i in options.models if i.startswith(sd.options.sd_model_checkpoint)] |
| 190 | if len(found) == 0: |
| 191 | log.error({ 'model error': sd.generate.sd_model_checkpoint, 'available': options.models}) |
| 192 | exit() |
| 193 | sd.options.sd_model_checkpoint = found[0] |
| 194 | data = await get('/sdapi/v1/samplers') |
| 195 | options.samplers = [obj['name'] for obj in data] |
| 196 | log.debug({ 'registered samplers': options.samplers }) |
| 197 | data = await get('/sdapi/v1/upscalers') |
| 198 | options.upscalers = [obj['name'] for obj in data] |
| 199 | log.debug({ 'registered upscalers': options.upscalers }) |
| 200 | data = await get('/sdapi/v1/face-restorers') |
| 201 | options.restorers = [obj['name'] for obj in data] |
| 202 | log.debug({ 'registered face restorers': options.restorers }) |
| 203 | await interrupt() |
| 204 | await post('/sdapi/v1/options', sd.options) |
| 205 | options.options = await get('/sdapi/v1/options') |
| 206 | log.info({ 'target models': { 'diffuser': options.options['sd_model_checkpoint'], 'vae': options.options['sd_vae'] } }) |
| 207 | log.info({ 'paths': sd.paths }) |
| 208 | options.queue = await get('/queue/status') |
| 209 | log.info({ 'queue': options.queue }) |
| 210 | pathlib.Path(sd.paths.root).mkdir(parents = True, exist_ok = True) |
| 211 | pathlib.Path(os.path.join(sd.paths.root, sd.paths.generate)).mkdir(parents = True, exist_ok = True) |
| 212 | pathlib.Path(os.path.join(sd.paths.root, sd.paths.upscale)).mkdir(parents = True, exist_ok = True) |
| 213 | pathlib.Path(os.path.join(sd.paths.root, sd.paths.grid)).mkdir(parents = True, exist_ok = True) |
| 214 | return options |
| 215 | |
| 216 | |
| 217 | def args(): # parse cmd arguments |