Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: conditional use of GradScaler based on device_type and dtype in train.py #481

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

BRAINIAC2677
Copy link

Problem:

Use of GradScaler gives AssertionError in train.py while using device = cpu.


Traceback (most recent call last): File "/home/brainiac77/github/neural-network-playground/gpt/train.py", line 305, in <module> scaler.scale(loss).backward() ^^^^^^^^^^^^^^^^^^ File "/home/brainiac77/miniconda3/envs/vision-1/lib/python3.12/site-packages/torch/cuda/amp/grad_scaler.py", line 203, in scale assert outputs.is_cuda or outputs.device.type == "xla" AssertionError

Fix:

Use a conditional to check device_type and dtype and based on that take decision whether to use GradScaler or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant