Reputation: 21
with autocast(device_type='cuda', dtype=torch.float16):
a=0.00000000000000001
print(a)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: __init__() got an unexpected keyword argument 'device_type'
I got this error in another tool I was using so I wanted to reproduce it and I run the above dummy code and I got it again. Anyone knows if it's a pytorch, cudatoolkit problem or something else? These are the relative packages I have in my anaconda environment:
pytorch 1.9.0 py3.8_cuda11.1_cudnn8.0.5_0 pytorch python 3.8.15 h7a1cb2a_2 cudatoolkit 11.1.74 h6bb024c_0 nvidia
And this is the error I initially came across in the training loop of a classification model I was using.
with autocast(dtype=self.precision):
TypeError: __init()__ got an unexpected keyword argument 'dtype'
Upvotes: 2
Views: 5336
Reputation: 716
If you're intending to use autocast module from pytorch, use it as following-
torch.autocast(device_type='cuda', dtype=torch.float16)
Upvotes: 1