Stability-AI / stablediffusion

High-Resolution Image Synthesis with Latent Diffusion Models
MIT License
38.33k stars 4.95k forks source link

enabled must be a bool (got str) occurs when I run basic command #317

Closed kotran88 closed 1 year ago

kotran88 commented 1 year ago

Hello :) I have issue with error saying enabled must be a bool (got str).

I commanded with command below python scripts/txt2img.py --prompt "a professional photograph of an astronaut riding a horse" --ckpt C:\Users\pedro\Downloads\512-base-ema.ckpt --H 512 --W 512 --steps 30 --seed -1 --n_samples 1 --n_iter 1 --precision=autocast

on scripts/txt2img.py,

I changed from torch import autocast to from torch.cuda.amp import autocast

on below, opt.device is 'cpu' and error caused


Traceback (most recent call last):
  File "C:\Users\pedro\stablediffusion\scripts\txt2img.py", line 387, in <module>
    main(opt)
  File "C:\Users\pedro\stablediffusion\scripts\txt2img.py", line 333, in main
    with torch.no_grad(), \
  File "C:\Users\pedro\anaconda3\envs\mydiffusion\lib\site-packages\torch\cuda\amp\autocast_mode.py", line 41, in __enter__
    return super().__enter__()
  File "C:\Users\pedro\anaconda3\envs\mydiffusion\lib\site-packages\torch\amp\autocast_mode.py", line 365, in __enter__
    torch.set_autocast_enabled(self._enabled)
TypeError: enabled must be a bool (got str)

on precison_scope(opt.device),\ <-- here

what may be the problem?


    precision_scope = autocast if opt.precision=="autocast" or opt.bf16 else nullcontext

    with torch.no_grad(), \
        precision_scope(opt.device), \
        model.ema_scope():
            all_samples = list()
            for n in trange(opt.n_iter, desc="Sampling"):
rajakolla2 commented 8 months ago

I also getting same error, could you please share solution for this.