選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

33 行
1.1KB

  1. import multiprocessing as mp
  2. import time
  3. from concurrent.futures import ProcessPoolExecutor
  4. from multiprocessing import Queue, shared_memory
  5. import tensorrt as trt
  6. # multiprocessing.set_start_method('spawn')
  7. Detweights = "/home/th/tuo_heng/dev/AIlib2/weights/river2/yolov5_2080Ti_fp16.engine"
  8. start = time.time()
  9. with open(Detweights, "rb") as f, trt.Runtime(trt.Logger(trt.Logger.ERROR)) as runtime:
  10. model = runtime.deserialize_cuda_engine(f.read())
  11. print(time.time() - start)
  12. start1 = time.time()
  13. Segweights = "/home/th/tuo_heng/dev/AIlib2/weights/river2/stdc_360X640_2080Ti_fp16.engine"
  14. with open(Segweights, "rb") as f, trt.Runtime(trt.Logger(trt.Logger.ERROR)) as runtime:
  15. segmodel = runtime.deserialize_cuda_engine(f.read())
  16. print(time.time() - start1)
  17. def aa(buf):
  18. print(id(buf[0]), id(buf[1]))
  19. shm = shared_memory.SharedMemory(name='share', create=True, size=10000)
  20. buf = shm.buf
  21. buf = model
  22. buf[1] = segmodel
  23. print(id(model), id(segmodel))
  24. p = mp.Process(target=aa, args=(buf,))
  25. p1 = mp.Process(target=aa, args=(buf,))
  26. p.start()
  27. p1.start()
  28. time.sleep(10)