본문 바로가기

개발일기

딥런이 잡동에러

1. onnx thread 개수 설정하기 .

[E:onnxruntime:Default, env.cc:254 ThreadMain] pthread_setaffinity_np failed for thread: 5639, index: 13, mask: {22, 62, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set.

 

session option 설정시에 아래와 같이 명시해준다. 

        sess_opts.inter_op_num_threads = 1
        sess_opts.intra_op_num_threads = 1

 

아래와 같이 session 설정한다. 

        sess_opts = ort.SessionOptions() # session 옵션
        
        device = 'cpu'
        providers = ['CPUExecutionProvider'
                 ] if device == 'cpu' else ['CUDAExecutionProvider']
        onnx_det = det_path
        onnx_pose = pose_path
        
        sess_opts.graph_optimization_level = ort.GraphOptimizationLevel.ORT_ENABLE_ALL #  최적화 수준 설정 
        sess_opts.inter_op_num_threads = 1 #########여기!!!!
        sess_opts.intra_op_num_threads = 1 #########여기!!!!
        sess_opts.execution_mode = ort.ExecutionMode.ORT_SEQUENTIAL # 순차실행 
        self.session_det = ort.InferenceSession(path_or_bytes=onnx_det,
                                                sess_options=sess_opts,
                                                providers=providers)
        self.session_pose = ort.InferenceSession(path_or_bytes=onnx_det,
                                                sess_options=sess_opts,
                                                providers=providers)