Improve error message: .numpy() not supported on cuda

I was struggling to feed my predictions into an sklearn function

M_ = M.data.numpy()

I got error

RuntimeError: numpy conversion for LongTensor is not supported

I tried some other things. Didn’t work and I gave up.
Then I start reading the docs. I found out it should be

M_ = M.data.cpu().numpy()

I suggest to improve this error message. Maybe something like

RuntimeError: numpy conversion for LongTensor is not supported on CUDA

That way, novices like me will know what to do

1 Like

thanks, it’s a good suggestion. i’ll work on this.

Tracking it here: https://github.com/pytorch/pytorch/issues/779