Module 'torch.cuda' has no attribute 'amp' with torch 1.6.0

I try to install pytorch 1.6.0 with pip.

torch 1.6.0+cu101
torchvision 0.7.0+cu101
cudatoolkit 10.1.243 h6bb024c_0 defaults

but I got a error:

scaler1 = torch.cuda.amp.GradScaler()

AttributeError: module ‘torch.cuda’ has no attribute ‘amp’

Could you post the output of print(torch.__version__), please?

thank you!

It’s strange.

print(torch.version)
1.2.0

Why there is another torch version in a new conda env?

It returns aother error, when I activate conda env again.
It returns:

ImportError: cannot import name ‘default_generator’

Unsure, but your virtual environment might have multiple PyTorch installations.
Could you create a new environment and install PyTorch 1.6 again?

@ptrblck …I created a new virtual environment. “pip list” returns torch 1.7.1 and torchvision 0.8.2. Still i am getting error “module ‘torch.cuda.amp’ has no attribute ‘Gradscaler’”.

Could you please help me out here sir??

Try to use GradScaler (uppercase S): torch.cuda.amp.GradScaler.

1 Like