How to serialize TensorRT model into file and deserialize from file? (Solved)

I find some examples to do this in c++ interface. But I don’t know how to do it in python. Some python examples just serialize and deserialize while not writing a serialization file as follows:

modelstream = engine.serialize()
runtime = trt.infer.create_infer_runtime(G_LOGGER)
engine = runtime.deserialize_cuda_engine(modelstream.data(), modelstream.size(), None)

Could someone help me about this issue? Thanks very much!

Usage:
trt.utils.write_engine_to_file
trt.utils.load_engine

@pikerbright using trt.utils.load_engine to deserialize from binary engine file could produce too much logs:

a6=\xb3K\t>\x8e\xb5$\xbe\xa5\xae\x1d\xbd:")>\xe4\x17\x04=@\x9a\xc8\xbd\x82I\x0c=\xb2L\xf5\xbdP4/\xbeO\xb0\xd0\xbdXN\x1f\xbb}\xb7\r\xbeUU\x83\xbd\xf6J<\xbd\xa7\x15\xbf\xbc\xa6\xa4\x0e>\xf1\x83%\xbe] J\xbd&p\x90=x_6=>CA\xbeu\x96\xe9\xbdyf\x93=\xc8\xc1\xad<\xa0\xa9\x07=\xff\x82t:O\xd0[=j\xa8C\xbd\xed\xba\x06<\x1f\xff\xe4=\x18\xf5\xd7\xbdT~\x91=\x0ed\x1a=\xb2\x13\xa9=\x17,\xc5=\xcf#\xd8\xbd\xdf+x\xbd\x84\xdcZ< \r/\xbd\x15y\x8d=oz\x07>\xe8i\x97=~\x10\t\xbeqr^=\x95\xcf\x01\xbcC\xc6;\xbd\x9e\x8cc\xbd\xe0\xefO\xbd\xf04P\xbcjCt<bnA\xbd\x84\xbf\xec\xbci

how to turn off these log? can you give some advises?R\xbdj\x97_<v?\xe0=\xcc\xf6\xcf\xba\xea\xc5\x9b=\x96\xf1\x9d<\x98\xa5\x08\xbdg>\x9b=\x17\x8a\xff;\xecN\x03\xbe\xf9\x03\x18>\xbed8\xbe\xc9nS=kVh=]\xfcy=\x9a\xe7\xd1<\xfe\x0c\xbe\xbd\xfc{\xc7=\x11\xdc\x1a>\x8e1\x05>\xc8\x03\xa9\xbd\xf1(\x07>\x1b%\t\xbe2\xe7\x1a\xbe\xc7\xa9K>\x96v\xb4=\xc8\xb9\x87=\x14\xfc\xb3=\xc5\xc3U=z\xcb\x01\xbe\xa5\xe6^=\xbb\xf2\xb2\xbc\xb3\xa0\xa5=\xfc\xcc\xc9\xbdcP\x8c\xbd\x87\xe2\xdc\xbdDK\\xbd\xa9\x9d9>\xb2\x9c\x89<A\xfb\xce\xbd}\xe9\xa6=\xa2k><\xb4f>\xbc\x8b\xca\x9b\xbd

how to turn off these log? can you give some advises?\xb47=h\x97\xed<\x18;G>\xbcRJ=\x81\x0e\x88=\xdb`\xe0;PIw\xbd\xe3\xcaZ=\xcd\x857<4\x11z\xbcpi\xc1\xbd\x0b\x1bV\xbbC\xa4\xc2\xbc\xe7\xc7\x18\xbe\x15g\x1a\xbeOr\x85=\x84u\x16=R\xd3\x93=\xed)u=\x05M|=\x08d\xa1<\xe7\xab\x14=\x1c\xc0:\xbd\xb7\xad\xe1=\xe3\xb7(\xbe,\x0b\xb9\xbc1L2\xbe7\xf1\xa4\xbd\xb59E=SD1>>\xc7\xd9\xbc\xea\xfal=\xad}\xe1\xbd\x9e\x93n\xbd\xaa@\x91\xbdK\x96\x13\xbe\xa2\xef\xb1=\xf3\xc3(=@\xe1r\xbc\x13\x0f%=\xf0W\xe5\xbd\x94\xe3\xaa<\x04n|=}^{\xbd\xd2\xee\x86\xbd\x12\x9eu=\xa5\xb8\x91<\xb2U+\xbdL\xda\x91=Yl\x03\xbe\x0e?\x0c=\x96\xf8\xaa=\x91\x01\xa7<4\xae\x00\xbe\xc4\xf6\x1a\xbe\x02JD=>F\x06<La\xcc\xbd\x13\xb1\xd5=\x90\xc8\xb6=\x1b#&\xbe?\x06d<^gS="\x04\xcf\xbd\xde\xe1\x8d\xbdE&R\xbc\xd6\x9b\xbe<\x1a\xf2\xf5\xbd\x98\x11\x1f<\xd3SD\xbcx \x19>\xc7\xe0\x0b\xbe\xb5\x0e\x0b>\xbbK\x16>\x01\x8f\x07>\xa6w*=r%2\xbd\x1fN\x17\xbe\xab\x1d\xa9<\xb5\x9fb\xbd\x18\x8b\x91=p\x0e\xc2\xbd\xe8\x06\x93==\xd0\r=\xd0\x89\x8d\xbd\x89O\x10\xbe\x95\xe6s\xbd\x1e\xd8\x95=\xf6\x925\xbd\xd9\x16\x99\xbd\xacv\xe8=\x08)\xe6=f\x0b(=\f\xd6=\n\\x9e\xbd|Q\xd1<\x87\x10\xcc\xbc\xca\x87\x06\xbe*\r9=\xce\t\x82=\xcbOF>\x19\x90\xcc\xbaJj\xab\xbdsI\x9d=\x14\xe9\xab=\x0f\xd4\xfe=\xc0\xeb\xb8\xbd\x0f\xe2\x1f<\xd9\xb0\xc0=\x0f\xeb\t\xbe\xc2V\xf7\xbc\xe9\xc3\x02\xbb\x15u\x8a\xbd\xc6d\xbe\xbc\x9d\xd1<>\x03\x13m\xbd}\x98\x15=\x85W\xe7<F\x7f\x05>\x00~\x94\xbd\x92q\n\xbd\xd6\xae\xd0<\xa0F\xb7\xbd\xa1\xe9]=\xbd\xd4{\xbdo\t\x86=\x0e=\x10\xbdC\xc8\r=\x9d,$\xbep\xb3)\xbe9\xa3\xd5=\xbdj \xbd\xe0I\xdd=\xf5\x0cs<\xb8+,>\xdc\x84J\xbd\x13\xc2A\xbe)\x80\xa2=.\xec\x8f=V\x9c\xa2\xbdfT\xe3\xba\xe2F\xe4\xbd\x1c\x10(=\xce\x80\xc5\xbcR\xe0\x82\xbc;\x0f\x80=\xf3?\x02\xbe\xfa\x1b\x15=

how to turn off these log? can you give some advises?\xb3\xbd\xbd\xd0i?\xbe\x07\xb3\xa3=o\xd8\x89\xbd\x1cP\xfe=\x12=\xa1=\x13L\xbe8\x8f\xb4\x11\xbe\x1d]\x9e=\x85\xd2\x07<\x1a}\xe6\xbd\x8e1\x92=W\x02\x0c\xbd\xf369<\x82\xaf\xdb\xbdYy<<\x19X\xe4\xbc\x1c\xab\xab<\x05}\xa6=Qj9>\xce\xad\xc8\xbd\x15\xed\xed=\xfd\xe1\x99\xbc\xc93\n\x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xc5=\x0

how to turn off these log? can you give some advises?