|
1234567891011121314151617181920212223242526272829303132 |
- import multiprocessing as mp
- import time
- from concurrent.futures import ProcessPoolExecutor
- from multiprocessing import Queue, shared_memory
-
- import tensorrt as trt
-
- # multiprocessing.set_start_method('spawn')
- Detweights = "/home/th/tuo_heng/dev/AIlib2/weights/river2/yolov5_2080Ti_fp16.engine"
- start = time.time()
- with open(Detweights, "rb") as f, trt.Runtime(trt.Logger(trt.Logger.ERROR)) as runtime:
- model = runtime.deserialize_cuda_engine(f.read())
- print(time.time() - start)
- start1 = time.time()
- Segweights = "/home/th/tuo_heng/dev/AIlib2/weights/river2/stdc_360X640_2080Ti_fp16.engine"
- with open(Segweights, "rb") as f, trt.Runtime(trt.Logger(trt.Logger.ERROR)) as runtime:
- segmodel = runtime.deserialize_cuda_engine(f.read())
- print(time.time() - start1)
-
- def aa(buf):
- print(id(buf[0]), id(buf[1]))
- shm = shared_memory.SharedMemory(name='share', create=True, size=10000)
- buf = shm.buf
- buf = model
- buf[1] = segmodel
- print(id(model), id(segmodel))
- p = mp.Process(target=aa, args=(buf,))
- p1 = mp.Process(target=aa, args=(buf,))
- p.start()
- p1.start()
- time.sleep(10)
-
|