0

I am trying to install tensorrt on my google collab notebook, i chose the GPU runtime type and ran the following command:

import os
import torch

when i run

torch.cuda.is_available()

it return "True". Next i run

!pip install git+https://github.com/facebookresearch/nougat
!pip install tensorrt
!pip install tensorflow

after i ran it several times, all the line in the output all start with "Requirement already satisfied" but when i ran:

!tensorrt -h

it said:

/bin/bash: line 1: tensorrt: command not found

Can someone tell me how i can install tensorrt ? I only have basic python programming background (i'm a first year university student) and this is the first time i use something like this so i'm sorry if the question or the description of the problem is bad.

1 Answer 1

0

You cannot run directly tensorrt command on Google Colab. But you can use it via Python environment.

First, install tensorrt

!pip install tensorrt-cu12

You can check if it is installed

import tensorrt as trt
print(trt.__version__)

If you see the version printout, you are ready to use it.

Below is an example exporting with torch_tensorrt for pytorch models: https://docs.pytorch.org/TensorRT/user_guide/saving_models.html:

import torch
import torch_tensorrt

model = MyModel().eval().cuda()
inputs = [torch.randn((1, 3, 224, 224)).cuda()]
# trt_ep is a torch.fx.GraphModule object
trt_gm = torch_tensorrt.compile(model, ir="dynamo", inputs=inputs)
torch_tensorrt.save(trt_gm, "trt.ep", inputs=inputs)

# Later, you can load it and run inference
model = torch.export.load("trt.ep").module()
model(*inputs)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.