-
Notifications
You must be signed in to change notification settings - Fork 174
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
[Bug] HAP transform crashes when using a GPU #1047
Comments
cc: @klwuibm |
I think we can add the following block at line 42:
|
I tested the fix of always executing .to(device) and it worked for both CPU & GPU ... matching what is done for inputs on line 54. |
@burn2l Thanks very much for raising this issue. I believe that one can always execute
|
The code already sets 'device' on line 24 and uses it on 'inputs' with .to(device) at line 54, so to be consistent .to(device) should be added to self.model. Having an if statement for just the model would be slightly confusing since it would suggest that one style is more appropriate than the other. A minor point but I think it would help readability. |
yes. @burn2l, you are absolutely right. The device already is set on line 24. So, we can safely add |
Search before asking
Component
Transforms/Other
What happened + What you expected to happen
When the HAP transform is run on a machine with a GPU it crashes with:
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument index in method wrapper_CUDA__index_select)
Reproduction script
Run pytest test/test_hap.py on a machine with a GPU
Anything else
Can be fixed by changing line 41 in dpk_hap/transform.py to:
self.model = AutoModelForSequenceClassification.from_pretrained(self.model_name_or_path).to(device)
OS
Red Hat Enterprise Linux (RHEL)
Python
3.11.x
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: