pesser / stable-diffusion

MIT License
1.03k stars 395 forks source link

cannot import name 'autocast' from 'torch' #14

Closed TheOneTrueGuy closed 1 year ago

TheOneTrueGuy commented 1 year ago

Got the conda env, installs, downloads and everything all working smoothly now, no error messages but upon running this pops up:

Traceback (most recent call last): File "stable-diffusion/scripts/txt2img.py", line 12, in from torch import autocast ImportError: cannot import name 'autocast' from 'torch' (/usr/local/envs/ldm/lib/python3.8/site-packages/torch/init.py)

KobeAmerijckxPT commented 1 year ago

Having the same issue currently unfortunately

Sample-design-alt commented 1 year ago

yes, I have the same issue for this problem.

synaestheory commented 1 year ago

For me, the issue was resolved by updating txt2img.py line 12 from from torch import autocast to from torch.cuda.amp import autocast.

I also needed to modify line 225 from with precision_scope("cuda"): to with precision_scope(True):. I am calling the CLI and passing --precision=autocast.