Hello,
I have a tensorflow model in .pb format which I want to transfer to tensorrt for inference. It takes a 1501503 image and output a vector of 9 values.
I used the following code for the transformation:
import tensorflow as tf import tensorrt as trt from tensorrt.parsers import uffparser import pycuda.driver as cuda import pycuda.autoinit import numpy as np from random import randint # generate a random test case from PIL import Image from matplotlib.pyplot import imshow #to show test case import time #import system tools import os from tensorflow.examples.tutorials.mnist import input_data import uff model_path = 'model.pb' with open(model_path, 'rb') as f: graph_def = tf.GraphDef() graph_def.ParseFromString(f.read()) uff_model = uff.from_tensorflow(graph_def, ['softmax_0']) G_LOGGER = trt.infer.ConsoleLogger(trt.infer.LogSeverity.ERROR) parser = uffparser.create_uff_parser() parser.register_input("inputs", (3,150,150), 0) parser.register_output("softmax_0") engine = trt.utils.uff_to_trt_engine(G_LOGGER, uff_model, parser, 1, 1 << 30) parser.destroy() runtime = trt.infer.create_infer_runtime(G_LOGGER) context = engine.create_execution_context() output = np.empty(9, dtype = np.float32) img = np.ones(shape=(3, 150, 150), dtype=np.float32) #alocate device memory d_input = cuda.mem_alloc(1 * img.size * img.dtype.itemsize) d_output = cuda.mem_alloc(1 * output.size * output.dtype.itemsize) bindings = [int(d_input), int(d_output)] stream = cuda.Stream() #transfer input data to device cuda.memcpy_htod_async(d_input, img, stream) #execute model context.execute(1, bindings) # context.enqueue(1, bindings, stream.handle, None) #transfer predictions back cuda.memcpy_dtoh_async(output, d_output, stream) #syncronize threads stream.synchronize() print ("Prediction: " + str(np.argmax(output))) print(output) But the following error has occurred:
Using output node softmax_0 Converting to UFF graph No. nodes: 857 [TensorRT] ERROR: cudnnSoftMaxLayer.cpp (75) - Cuda Error in execute: 3 [TensorRT] ERROR: cudnnSoftMaxLayer.cpp (75) - Cuda Error in execute: 3 Would you please take a look?
Thanks in advance