torch2trt
torch2trt copied to clipboard
TypeError: 'module' object is not callable
hi, when I was running this code:
import torch import os from torch2trt import torch2trt from torchvision.models.resnet import resnet18
os.environ["CUDA_VISIBLE_DEVICES"]="2" model = resnet18(pretrained=True).eval().cuda() x = torch.ones((1, 3, 224, 224)).cuda() model_trt = torch2trt(model, [x]) torch.save(model_trt.state_dict(), 'resnet18_trt.pth')
then, there comes out "TypeError: 'module' object is not callable" how can I fix that?
waiting for your answer! THX!
Hi songqi-github,
Thanks for reaching out!
Do you witness this behavior without os.environ["CUDA_VISIBLE_DEVICES"]="2"
?
Also, do you mind sharing
- PyTorch Version
- TensorRT version
- Torchvision Version
- Platform (ie: Jetson Xavier, etc.)
Best, John
Hi even I am getting the same error any help highly appreciated!!
load net
cfg = widerface_640 num_classes = len(WIDERFace_CLASSES) + 1 # +1 background net = build_ssd('test', cfg['min_dim'], num_classes) # initialize SSD net.load_state_dict(torch.load(args.trained_model))
net.cuda() net.eval()
import tensorrt as trt data = torch.randn((1, 3, 640, 640)) data = torch.cuda.FloatTensor(data) temp = torch2trt(net, [data])
Traceback (most recent call last):
File "widerface_val.py", line 249, in
Hi, I got the same error without os.environ["CUDA_VISIBLE_DEVICES"]="2".
PyTorch Version==1.3.0 TensorRT version==6.0.1.5 Torchvision Version==0.4.1
hi @yashraj02 Have you solved this problem?
@songqi-github I get the same error.Do you solve it?
anyone use 'import torch2trt' replace 'from torch2trt import torch2trt' ?
Hi, all. I meet the same problem, have anyone alreadly solved this issue?
Hi guys, I think what you should write is model_trt = torch2trt.torch2trt(model, [x])
instead of model_trt = torch2trt(model, [x])
.
Hope this helps!
@Tony-Yan2018 Yes, your answer help me and now it works well! Thanks
Hi @jaybdub , I am facing the same error. I tried the above suggestion. It dint work. Any other alternatives?
@Tony-Yan2018 appreciate your advice, I tried it but the new error torch2trt has no attribute torch2trt was acquired. could you help me? thanks in advance
Hi guys, I think what you should write is
model_trt = torch2trt.torch2trt(model, [x])
instead ofmodel_trt = torch2trt(model, [x])
. Hope this helps!
@sjtuherisson I used it replaced. but the 'module' object is not callable was acquired.
anyone use 'import torch2trt' replace 'from torch2trt import torch2trt' ?