Argmax unexpected key and Cant convert Cuda tensor to Numpy error
See original GitHub issueHi I am facing the issue below. I have installed fast-bert using pip and just copied the code from the readme. Any suggestions on how to fix?
model/tensorboard
Traceback (most recent call last):
File "/usr1/home/rjoshi2/envs/myenv/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 61, in _wrapfunc
return bound(*args, **kwds)
TypeError: argmax() got an unexpected keyword argument 'axis'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "train_bert.py", line 67, in <module>
main()
File "train_bert.py", line 62, in main
optimizer_type="lamb")
File "/usr1/home/rjoshi2/envs/myenv/lib/python3.7/site-packages/fast_bert/learner_cls.py", line 406, in fit
results = self.validate()
File "/usr1/home/rjoshi2/envs/myenv/lib/python3.7/site-packages/fast_bert/learner_cls.py", line 524, in validate
all_logits, all_labels
File "/usr1/home/rjoshi2/envs/myenv/lib/python3.7/site-packages/fast_bert/metrics.py", line 15, in accuracy
outputs = np.argmax(y_pred, axis=1)
File "<__array_function__ internals>", line 6, in argmax
File "/usr1/home/rjoshi2/envs/myenv/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 1153, in argmax
return _wrapfunc(a, 'argmax', axis=axis, out=out)
File "/usr1/home/rjoshi2/envs/myenv/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 70, in _wrapfunc
return _wrapit(obj, method, *args, **kwds)
File "/usr1/home/rjoshi2/envs/myenv/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 47, in _wrapit
result = getattr(asarray(obj), method)(*args, **kwds)
File "/usr1/home/rjoshi2/envs/myenv/lib/python3.7/site-packages/numpy/core/_asarray.py", line 85, in asarray
return array(a, dtype, copy=False, order=order)
File "/usr1/home/rjoshi2/envs/myenv/lib/python3.7/site-packages/torch/tensor.py", line 433, in __array__
return self.numpy()
TypeError: can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8
Top Results From Across the Web
Argmax unexpected key and Cant convert Cuda tensor to ...
Hi I am facing the issue below. I have installed fast-bert using pip and just copied the code from the readme. Any suggestions...
Read more >can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy ...
to index = output.cpu().data.numpy().argmax(). This means data is first moved to cpu and then converted to numpy array.
Read more >can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy ...
cpu() to copy the tensor to host memory first. TypeError: can't convert CUDA tensor to numpy. Use Tensor. cpu() to copy the tensor...
Read more >torch.Tensor — PyTorch master documentation
Current implementation of torch.Tensor introduces memory overhead, thus it might lead to unexpectedly high memory usage in the applications with many tiny ...
Read more >CuPy Documentation - Read the Docs
CuPy is a NumPy/SciPy-compatible array library for GPU-accelerated computing with Python. CuPy acts as a drop-in.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
facing same issue in lastest version, i belived its 1.60 , i am using google colab
This occurs with the new version released today. Try pip installling version 1.5.0.