Description
Hello,
I have the Jetson AGX Orin, and I’m trying to create a simple pipeline in Rust for TensorRT.
I’ve tried to use TensorRT — Rust gfx library // Lib.rs but the create depends on tch = “0.14.0”, and it’s not good because of a lot of dependencies.
The crate tch is used for the preparation of images to TensorRT.
Here is an example code
let image = load_image_and_resize224(&image_path).unwrap();
let image = image.contiguous();
let image = image.unsqueeze(0);
let host_ptr = image.data_ptr();
cuda_rs::init()?;
let input_shape = Shape(vec![1, 3, 224, 224]);
let output_shape = Shape(vec![1, 768]);
let dtype = DataType::FLOAT;
let mem_size = input_shape.size() * dtype.get_elem_size();
let device = CuDevice::new(0)?;
let ctx = device.retain_primary_context()?;
let _guard = ctx.guard()?;
let stream = CuStream::new()?;
let input_tensor = Tensor::empty(&input_shape, dtype, &stream)?;
input_tensor.get_memory().copy_from_raw(
host_ptr as _, mem_size, Some(&stream)
)?;
Could someone share own example of how to make pre-processing for an image or may be some wrapper ?
I tried to understand how tch is working but I couldn’t manage it because of my lower experience.
Thanks
Environment
TensorRT Version: 8.6.2.3
GPU Type:
Nvidia Driver Version:
CUDA Version: 12.2
CUDNN Version:
Operating System + Version: Ubuntu
Python Version (if applicable):
TensorFlow Version (if applicable):
PyTorch Version (if applicable):
Baremetal or Container (if container which image + tag):