dlib 샘플의 컴파일로 cuDNN V5.0 OR GREATER NOT FOUND라고 했을 때

7821 단어 CUDAdlib
환경: Max OS X El Capitan
dlib: v19.2

dlib 샘플 브로그램 빌드 실패



컴파일 방법에 따라 dlib의 샘플 브로그램을 빌드 한 결과 다음과 같은 오류가 발생했습니다.
% cmake ..
-- C++11 activated.
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE  
-- Looking for png_create_read_struct
-- Looking for png_create_read_struct - found
-- Looking for jpeg_read_header
-- Looking for jpeg_read_header - found
-- Searching for BLAS and LAPACK
-- Found PkgConfig: /usr/local/bin/pkg-config (found version "0.29.1")
-- Checking for module 'cblas'
--   No package 'cblas' found
-- Checking for module 'lapack'
--   No package 'lapack' found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of void*
-- Check size of void* - done
-- Found LAPACK library
-- Found CBLAS library
-- Looking for cblas_ddot
-- Looking for cblas_ddot - found
-- Found CUDA: /Developer/NVIDIA/CUDA-8.0 (found suitable version "8.0", minimum required is "7.5")
-- Looking for cuDNN install...
-- Building a CUDA test project to see if your compiler is compatible with CUDA...
-- Checking if you have the right version of cuDNN installed.
-- *** Found cuDNN, but it looks like the wrong version so dlib will not use it. ***
-- *** cuDNN V5.0 OR GREATER NOT FOUND.  DLIB WILL NOT USE CUDA. ***
-- *** If you have cuDNN then set CMAKE_PREFIX_PATH to include cuDNN's folder.
OpenCV not found, so we won't build the webcam_face_pose_ex example.
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/mkisono/work/dlib/examples/build

CMAKE_PREFIX_PATH를 붙여도 결과는 동일했습니다.
% cmake -DCMAKE_PREFIX_PATH=/Developer/NVIDIA/CUDA-8.0  .. 

같은 기계에서 Theano와 같은 다른 도구는 cuDNN을 사용할 수 있습니다. cuDNN의 설치 자체는 문제 없다고 생각되었으므로, 원인을 조사해 보았습니다.

cudnn_test를 빌드하여 원인 찾기



"cuDNN V5.0 OR GREATER NOT FOUND"라고 나오는 것은 cuDNN을 포함한 테스트 프로젝트 빌드에 실패했기 때문에입니다. 어떤 오류가 발생합니까?
% mkdir build
% cd build 
% cmake ../dlib/cmake_utils/test_for_cudnn
% cmake --build .
Scanning dependencies of target cudnn_test
[ 50%] Building CXX object CMakeFiles/cudnn_test.dir/Users/mkisono/work/dlib/dlib/dnn/cudnn_dlibapi.cpp.o
/Users/mkisono/work/dlib/dlib/dnn/cudnn_dlibapi.cpp:117:13: error: thread-local storage is not supported for the current target
            thread_local cudnn_context c;
            ^
/Users/mkisono/work/dlib/dlib/dnn/cudnn_dlibapi.cpp:156:13: error: thread-local storage is not supported for the current target
            thread_local cudnn_activation_descriptor des(CUDNN_ACTIVATION_RELU, CUDNN_PROPAGATE_NAN,0);
            ^
/Users/mkisono/work/dlib/dlib/dnn/cudnn_dlibapi.cpp:162:13: error: thread-local storage is not supported for the current target
            thread_local cudnn_activation_descriptor des(CUDNN_ACTIVATION_SIGMOID, CUDNN_PROPAGATE_NAN,0);
            ^
/Users/mkisono/work/dlib/dlib/dnn/cudnn_dlibapi.cpp:168:13: error: thread-local storage is not supported for the current target
            thread_local cudnn_activation_descriptor des(CUDNN_ACTIVATION_TANH, CUDNN_PROPAGATE_NAN,0);
            ^
4 errors generated.
make[2]: *** [CMakeFiles/cudnn_test.dir/Users/mkisono/work/dlib/dlib/dnn/cudnn_dlibapi.cpp.o] Error 1
make[1]: *** [CMakeFiles/cudnn_test.dir/all] Error 2
make: *** [all] Error 2

Xcode 버전 업그레이드



"error: thread-local storage is not supported for the current target"오류의 원인은 Xcode가 버전 7.3이었기 때문입니다. 최신 버전으로 버전 업하고 다시 test_for_cudnn 을 빌드했는데 이번에는 잘 갔습니다.


% cmake --build .
[ 50%] Building CXX object CMakeFiles/cudnn_test.dir/Users/mkisono/work/dlib/dlib/dnn/cudnn_dlibapi.cpp.o
[100%] Linking CXX static library libcudnn_test.a
[100%] Built target cudnn_test

이번에는 cuda_test를 빌드 할 수 없습니다.



이것으로 끝이 아니었다. 이번에는 CUDA의 test project를 빌드할 수 없는 상태가 되었다. 뭐야, 이 당당한 순회는··
-- Found CUDA: /Developer/NVIDIA/CUDA-8.0 (found suitable version "8.0", minimum required is "7.5")
-- Looking for cuDNN install...
-- Building a CUDA test project to see if your compiler is compatible with CUDA...
-- *** CUDA was found but your compiler failed to compile a simple CUDA program so dlib isn't going to use CUDA. ***
-- *** cuDNN V5.0 OR GREATER NOT FOUND.  DLIB WILL NOT USE CUDA. ***
-- *** If you have cuDNN then set CMAKE_PREFIX_PATH to include cuDNN's folder.

CUDA toolkit이 오래되면 Xcode 8이 지원되지 않음 같다. 어쩔 수 없기 때문에 이번에는 CUDA toolkit를 새롭게 한다.

오류가 발생한 버전.
% nvcc -V                                                                                                     [~/work/dlib/build]
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Sun_Sep_18_22:16:08_CDT_2016
Cuda compilation tools, release 8.0, V8.0.46

업데이트 후 버전.
% nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Sun_Oct_30_22:18:43_CDT_2016
Cuda compilation tools, release 8.0, V8.0.54

everything works fine, at last.



cuda_test 프로젝트 빌드 성공
% cmake --build .                                                                                             [~/work/dlib/build]
[ 50%] Building NVCC (Device) object CMakeFiles/cuda_test.dir/cuda_test_generated_cuda_test.cu.o
Scanning dependencies of target cuda_test
[100%] Linking CXX static library libcuda_test.a
[100%] Built target cuda_test

그리고 마침내 샘플 cmake가 통과했습니다.
% cmake ..
-- C++11 activated.
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE  
-- Looking for png_create_read_struct
-- Looking for png_create_read_struct - found
-- Looking for jpeg_read_header
-- Looking for jpeg_read_header - found
-- Searching for BLAS and LAPACK
-- Found PkgConfig: /usr/local/bin/pkg-config (found version "0.29.1")
-- Checking for module 'cblas'
--   No package 'cblas' found
-- Checking for module 'lapack'
--   No package 'lapack' found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of void*
-- Check size of void* - done
-- Found LAPACK library
-- Found CBLAS library
-- Looking for cblas_ddot
-- Looking for cblas_ddot - found
-- Found CUDA: /Developer/NVIDIA/CUDA-8.0 (found suitable version "8.0", minimum required is "7.5")
-- Looking for cuDNN install...
-- Building a CUDA test project to see if your compiler is compatible with CUDA...
-- Checking if you have the right version of cuDNN installed.
-- Found cuDNN: /usr/local/cuda/lib/libcudnn.dylib
OpenCV not found, so we won't build the webcam_face_pose_ex example.
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/mkisono/work/dlib/examples/build

요약



개발 도구는 자주 업데이트하는 것이 좋을 것 같네요.

좋은 웹페이지 즐겨찾기