나의 경우 Face Detection 모델과 Face alignment 모델 두가지를 돌려야 하는 상황이 있었는데 (나중에 Face detection과 Face alignment에 관해 간단히 정리해야겠다.0
1. 발생이유.
OpenCV에서 Face Detection 모델을 사용해서 얼굴이 인식 되고 나면 그 후에
Tensorflow 에서 Face Alignment 모델이 돌아가는 방식을 사용 하고 있었는데
Face Alignment 모델만 단독으로 사용할 경우 CUDA에서 동작은 했지만 두모델을 같이 돌리기 시작하면
cudnn_status_internal_error가 발생하며 튕기는 현상이 발생했다.
처음 Tensorflow가 초기화 되었을 때 gpu 메모리가 한번에 로드되는 게 아니라 Face가 인식 되고 난 후 메모리가 로드되어 internal_error가 발생한다.
2. 해결방안
세션을 시작할 때 Session Option에 set_allow_growth 옵션을 True로 하면 해결된다.
auto options = tensorflow::SessionOptions();
options.config.mutable_gpu_options()->set_per_process_gpu_memory_fraction(0.2);
options.config.mutable_gpu_options()->set_allow_growth(true);
tensorflow::Status status = tensorflow::NewSession(options, &session);
혹여나 cudnn_status_internal_error 가 발생하는데 cudnn.so 등등 다 링크가 잘 되어있는데도 이런게 생기면 꼭 한번 해보기 바란다.
몰라서 나는 개고생 했다. 한 24시간 정도..?