mlcommons / inference_results_v1.1

This repository contains the results and code for the MLPerf™ Inference v1.1 benchmark.
https://mlcommons.org/en/inference-datacenter-11/
Apache License 2.0
11 stars 23 forks source link

Install tenosrrt for python3.8 in Jetson Xavier NX #6

Open zhr01 opened 3 years ago

zhr01 commented 3 years ago

I try to achive the result in Nvidia Jetson Xavier NX. After setup up the environment, I got the fllowing error message:

Makefile:236: *** MLPerf Inference v1.1 code requires NVIDIA Driver Version >= 465.xx.  Stop

then I check the environment, found the tensorrt not in my python3.8 env, so how can I install tensorrt for python3.8

nvitramble commented 3 years ago

Could you share the commands you've run so far, as well as the output of running python3 scripts/get_system_id.py from the closed/NVIDIA directory? Thanks

yzh89 commented 3 years ago

The python3-libnvinfer only works with python3.6. There are some discussion here: https://forums.developer.nvidia.com/t/python-binding-not-found-for-tensorrt/76408.

It looks like the python3.8 binding needed to created with manual binding

Treemann commented 2 years ago

Hi @zhr01 , have you solved the problem?

I followed the instruction to set up the environment for testing on Jetson AGX Xavier, everything went fine for running the script install_xavier_dependencies.sh, but when I ran the script for data preprocessing, error occurred that: No module named 'tensorrt'

I noticed that in 'install_xavier_dependencies.sh' python3.8 was installed and set as the default version of python3, but python3.8 could not import 'tensorrt'. I tried to "import tensorrt" with python3.6 and no error occurred.

So @nvitramble , do I miss something in the official instruction? Should I manually compile & build the .whl for using tensorrt with python3.8?

What's more, I check the instruction of build the python binding, and find that I can not find the 'PyConfig.h' file for python3.8 (on aarch64) according to the link NVIDIA provided in this section 'Add PyConfig.h'. How can I build the binding for python3.8?

psyhtest commented 2 years ago

@Treemann It looks like we are banging our heads against the same wall and at the same time!

FWIW, I've tried to take pyconfig.h from a non-architecture specific python3.8 package and an aarch-specific python3.9 package, but nothing's worked.

/cc @nvpohanh @DilipSequeira

Treemann commented 2 years ago

Hi @psyhtest I could find the 'PyConfig.h' on the location where Python3.8 was installed. I built the 'python binding' for Python3.8 successfully and finally could run the script for testing. (FYI: I tried with the code for MLPerf v1.1)

psyhtest commented 2 years ago

@Treemann, that's great to hear! I was beginning to suspect that something else was wrong. I'll give it another try.

psyhtest commented 2 years ago

@yzh89 Please try these instructions (copying and pasting the whole block should work).

wangxudong-cq commented 2 years ago

@psyhtest well done. But followed by a segfault on "reate_network" as blow: script

import numpy as np

def pyBuilder(framework):
    if framework=="trt":
        import tensorrt as rt
        logger=rt.Logger(rt.Logger.WARNING)

    with rt.Builder(logger) as builder:
        print("--------------------------------------")
        with builder.create_network(1 << int(rt.NetworkDefinitionCreationFlag.EXPLICIT_BATCH)) as network:
            print("--------------------------------------")
            INPUT_NAME="input"
            INPUT_SHAPE=(3,5,5)
            input_tensor = network.add_input(name=INPUT_NAME, dtype=rt.float32, shape=INPUT_SHAPE)
            conv1_w = np.random.random(size=(3,3,5))
            conv1_w.dtype = "float32"
            conv1_b = np.random.random(size=(3))
            conv1_b.dtype = "float32"
            conv1 = network.add_convolution(input=input_tensor, num_output_maps=20, kernel_shape=(5, 5), kernel=conv1_w, bias=conv1_b)
            conv1.stride = (1, 1)
            print(type(conv1))
            print(dir(conv1))
            print(conv1.kernel_size)
            conv1.kernel_size=(7,7)
            print(conv1.kernel_size)
            print(conv1.num_output_maps)
            print(conv1.stride)
            print(conv1.padding)
            print(conv1.num_output_maps)
            print(conv1.num_groups)
            conv1.num_groups=21
            print(conv1.get_input(0))
            print(dir(conv1.get_input(0)))
            print(conv1.get_input(1))
            print(conv1.get_input(-1))

pyBuilder("trt")

output

load lib: /usr/local/lib/python3.8/dist-packages/tensorrt/tensorrt.so
8.2.5.1
--------------------------------------
Segmentation fault
wangxudong-cq commented 2 years ago

May caused by the mismatch between tensorrt python API and tensorrt.so?