<jupyter_start><jupyter_text>Build TensorRT modelTensorRT is used to optimize the neural network model trained  TensorRT If *torch2trt* is not installed, first execute these commands in the console.```bashcd $HOMEgit clone https://github.com/NVIDIA-AI-IOT/torch2trtcd torch2trtsudo python3 setup.py install```  Imports and load the trained model<jupyter_code>import torch
import torchvision

model = torchvision.models.resnet18(pretrained=False)
model.fc = torch.nn.Linear(512, 2)
model = model.cuda().eval().half()

# Loading the trained weights and transfer to the GPU device
model.load_state_dict(torch.load('model.pth'))
device = torch.device('cuda')<jupyter_output><empty_output><jupyter_text>Using TensorRT and save the model<jupyter_code>from torch2trt import torch2trt

data = torch.zeros((1, 3, 224, 224)).cuda().half()

model_trt = torch2trt(model, [data], fp16_mode=True)

torch.save(model_trt.state_dict(), 'model_trt.pth')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11398963730569948, 'fraction_numerical': 0.02383419689119171, 'mean_word_length': 6.983471074380165, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '204122', 'license': 'MIT', 'n_tokens_mistral': 343, 'n_tokens_neox': 329, 'n_words': 80, 'path': 'build_trt.ipynb', 'repo_name': 'milager/Pet-feeder', 'size': '965'}