jeffbinder / visions-and-revisions

Neural network poetry rewriter
21 stars 4 forks source link

Device issue - gpt2 models on gpu #1

Closed GenTxt closed 3 years ago

GenTxt commented 3 years ago

Thanks for the cool repo. Have everything working fine for bert and roberta models but running into a problem when trying to use default and custom gpt2 models with same parameters in new notebook on gpu.

Original version of notebook works 100% with gpt2 but only works on cpu.

I've converted the notebooks to .py scripts for convenience. The error is always the same:

File "/home/pixelhead/Desktop/visions-and-revisions-master/visions.py", line 425, in adjust_probs adj_probs[k][j] *= (1.0 - word_pieces.to(device))

RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

I added to the parody section in 'vision.py' : model.to(device) model.eval() ... original script continues

but this created a new error:

RuntimeError: Expected object of device type cuda but got device type cpu for argument #3 'index' in call to _th_index_select

Not sure what the issue is for gpt2. I would appreciate any suggestions to edit script.

Cheers

jeffbinder commented 3 years ago

Thanks for trying it out! It looks like there were some more .to(device) calls missing. I just pushed a change that should fix it—let me know if there are any further problems.

GenTxt commented 3 years ago

Thanks. Everything working 100% now.

cheers

On Wed, Dec 2, 2020 at 10:52 PM Jeffrey M. Binder notifications@github.com wrote:

Closed #1 https://github.com/jeffbinder/visions-and-revisions/issues/1.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jeffbinder/visions-and-revisions/issues/1#event-4065428264, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFMAWPKVKHXNXWPAOEM7VNDSS4DPNANCNFSM4ULESO4A .