cannot import name 'autocast' from 'torch'
TheOneTrueGuy opened this issue · comments
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)
Having the same issue currently unfortunately
yes, I have the same issue for this problem.
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
.