среда
[*] libtorch 2.5.0.dev (последний вечер) (построен с Cuda 12.4) cuda 12.4 < /li>
tensorrt 10.1.0.27 < /li>
pytorch 2.4.0+cu124 < /li>
Torch-tensorrt 2.4.0 < /li>
python 3.12.8 < /li>
Windows 10 < /li>
< /ul>
Скомпилируйте фальшивый-Тенсорт с Cmake для генерации lib и dll
< /p>
опция: экспорт < /h3>
Если вы хотите оптимизировать свою модель заранее и /или развернуть в среде C ++ , Torch-Tensorrt обеспечивает рабочий процесс в стиле экспорта, который сериализует оптимизированный модуль. Этот модуль может быть развернут в Pytorch или с помощью Libtorch (то есть без зависимости от питона). < /P>
Шаг 1: оптимизация + serialize < /h4>
import torch
import torch_tensorrt
model = MyModel().eval().cuda() # define your model here
inputs = [torch.randn((1, 3, 224, 224)).cuda()] # define a list of representative inputs here
trt_gm = torch_tensorrt.compile(model, ir="dynamo", inputs)
torch_tensorrt.save(trt_gm, "trt.ep", inputs=inputs) # PyTorch only supports Python runtime for an ExportedProgram. For C++ deployment, use a TorchScript file
torch_tensorrt.save(trt_gm, "trt.ts", output_format="torchscript", inputs=inputs)
< /code>
Шаг 2: развертывание < /h4>
развертывание в c ++: < /h5>
#include "torch/script.h"
#include "torch_tensorrt/torch_tensorrt.h"
auto trt_mod = torch::jit::load("trt.ts");
auto input_tensor = [...]; // fill this with your inputs
auto results = trt_mod.forward({input_tensor});
ошибка
auto trt_mod = torch::jit::load("trt.ts")
Unknown type name '__torch__.torch.classes.tensorrt.Engine':
File "code/__torch__/torch_tensorrt/dynamo/runtime/_TorchTensorRTModule.py", line 6
training : bool
_is_full_backward_hook : Optional[bool]
engine : __torch__.torch.classes.tensorrt.Engine
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`your text`~~~~~~~~ Tensor:
Подробнее здесь: https://stackoverflow.com/questions/794 ... on-windows
Модель загрузки ошибок с использованием Torch Tensorrt в Libtorch в Windows ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
C ++ Libtorch "TORCH :: Make_shared <> ()": галлюцинация или история? [закрыто]
Anonymous » » в форуме C++ - 0 Ответы
- 11 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Ошибка трансляции при попытке ускорить модель сегментации с помощью TensorRT 10.7
Anonymous » » в форуме Python - 0 Ответы
- 11 Просмотры
-
Последнее сообщение Anonymous
-