torchstat
torchstat copied to clipboard
【bug】installing torchstat causes model(tensor) doesn't work!
After installing torchstat, the following code won't work!
model.cuda()
tensor = tensor.cuda()
model(tensor)
and the error traces back to 👍
~/miniconda3/lib/python3.7/site-packages/torchstat/model_hook.py in wrap_call(module, *input, **kwargs)
45
46 # Itemsize for memory
---> 47 itemsize = input[0].detach().numpy().itemsize
48
49 start = time.time()
TypeError: can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.
however,once uninstalling torchstat, everything returns fine.
After installing torchstat, the following code won't work!
model.cuda() tensor = tensor.cuda() model(tensor)
and the error traces back to
~/miniconda3/lib/python3.7/site-packages/torchstat/model_hook.py in wrap_call(module, *input, **kwargs) 45 46 # Itemsize for memory ---> 47 itemsize = input[0].detach().numpy().itemsize 48 49 start = time.time() TypeError: can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.
however,once uninstalling torchstat, everything returns fine.
Same prob. Seems like torchstat only support 'cpu'. BTW, why did this module have impact on another module?
After installing torchstat, the following code won't work!
model.cuda() tensor = tensor.cuda() model(tensor)
and the error traces back to
~/miniconda3/lib/python3.7/site-packages/torchstat/model_hook.py in wrap_call(module, *input, **kwargs) 45 46 # Itemsize for memory ---> 47 itemsize = input[0].detach().numpy().itemsize 48 49 start = time.time() TypeError: can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.
however,once uninstalling torchstat, everything returns fine.
Solved. Can refer to my repo: https://github.com/ChenZhouUC/TorchStats
I modified a little and marked it as an inherited repo.