torchstat icon indicating copy to clipboard operation
torchstat copied to clipboard

【bug】installing torchstat causes model(tensor) doesn't work!

Open aiyolo opened this issue 5 years ago • 2 comments

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.

aiyolo avatar Jan 03 '20 05:01 aiyolo

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?

ChenZhouUC avatar Jul 27 '20 12:07 ChenZhouUC

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.

ChenZhouUC avatar Jul 27 '20 14:07 ChenZhouUC