python - 为什么我得到 "dlib isn' t going to use CUDA"when I compile dlib python interface

标签 python python-3.x dlib

我在启用了 CUDA 9.1 的 Ubuntu 16.04 上使用 cmake 3.11.0 编译了 dlib 19.10。一切顺利,没有遇到任何问题!

这里是运行 cmake ..

的输出
-- The C compiler identification is GNU 5.4.1
-- The CXX compiler identification is GNU 5.4.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Found X11: /usr/lib/x86_64-linux-gnu/libX11.so
-- 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
-- Searching for BLAS and LAPACK
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") 
-- Checking for module 'cblas'
--   No package 'cblas' found
-- Checking for module 'lapack'
--   Found lapack, version 0.2.18
-- 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 OpenBLAS library
-- Looking for sgetrf_single
-- Looking for sgetrf_single - found
-- Using OpenBLAS's built in LAPACK
-- Looking for cblas_ddot
-- Looking for cblas_ddot - found
-- Looking for sgesv
-- Looking for sgesv - not found
-- Looking for sgesv_
-- Looking for sgesv_ - not found
-- Found CUDA: /usr/local/cuda-9.1 (found suitable version "9.1", minimum required is "7.5") 
-- Looking for cuDNN install...
-- Found cuDNN: /usr/lib/x86_64-linux-gnu/libcudnn.so
-- 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 OpenMP_C: -fopenmp (found version "4.0") 
-- Found OpenMP_CXX: -fopenmp (found version "4.0") 
-- Found OpenMP: TRUE (found version "4.0")  
-- Enabling CUDA support for dlib.  DLIB WILL USE CUDA
-- C++11 activated.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/peshmerge/Downloads/dlib-19.10/build

但是当我运行 sudo python3.5 setup.py install 时,我收到一条消息,提示已找到 CUDA,但它不会被使用:

-- *** CUDA was found but your compiler failed to compile a simple CUDA program so dlib isn't going to use CUDA. 

虽然它向我展示了发现 CUDA 和 CuDNN 之前:

-- Found CUDA: /usr/local (found suitable version "9.1", minimum required is "7.5") 
-- Looking for cuDNN install...
-- Found cuDNN: /usr/lib/x86_64-linux-gnu/libcudnn.so

这是我运行 sudo python3.5 setup.py install 时的全部输出:

peshmerge@darkage-x580vd:~/Downloads/dlib-19.10$ sudo python3.5 setup.py install
running install
Checking .pth file support in /usr/local/lib/python3.5/dist-packages/
/usr/bin/python3.5 -E -c pass
TEST PASSED: /usr/local/lib/python3.5/dist-packages/ appears to support .pth files
running bdist_egg
running egg_info
creating dlib.egg-info
writing dlib.egg-info/PKG-INFO
writing dependency_links to dlib.egg-info/dependency_links.txt
writing top-level names to dlib.egg-info/top_level.txt
writing manifest file 'dlib.egg-info/SOURCES.txt'
package init file 'dlib/__init__.py' not found (or not a regular file)
reading manifest file 'dlib.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'dlib.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
running build_ext
Invoking CMake setup: 'cmake /home/peshmerge/Downloads/dlib-19.10/tools/python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/peshmerge/Downloads/dlib-19.10/build/lib.linux-x86_64-3.5 -DPYTHON_EXECUTABLE=/usr/bin/python3.5 -DCMAKE_BUILD_TYPE=Release'
-- The C compiler identification is GNU 5.4.1
-- The CXX compiler identification is GNU 5.4.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: /usr/bin/python3.5 (found version "3.5.2") 
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.5m.so
-- Performing Test HAS_CPP14_FLAG
-- Performing Test HAS_CPP14_FLAG - Success
-- pybind11 v2.2.2
-- Enabling SSE4 instructions
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Found X11: /usr/lib/x86_64-linux-gnu/libX11.so
-- 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
-- Searching for BLAS and LAPACK
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") 
-- Checking for module 'cblas'
--   No package 'cblas' found
-- Checking for module 'lapack'
--   Found lapack, version 0.2.18
-- 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 OpenBLAS library
-- Looking for sgetrf_single
-- Looking for sgetrf_single - found
-- Using OpenBLAS's built in LAPACK
-- Looking for cblas_ddot
-- Looking for cblas_ddot - found
-- Looking for sgesv
-- Looking for sgesv - not found
-- Looking for sgesv_
-- Looking for sgesv_ - not found
-- Found CUDA: /usr/local (found suitable version "9.1", minimum required is "7.5") 
-- Looking for cuDNN install...
-- Found cuDNN: /usr/lib/x86_64-linux-gnu/libcudnn.so
-- 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. 
-- *** The output of the failed CUDA test compile is shown below: 
-- ***   Change Dir: /home/peshmerge/Downloads/dlib-19.10/build/temp.linux-x86_64-3.5/dlib_build/cuda_test_build
   ***   
   ***   Run Build Command:"/usr/bin/make"
   ***   [ 50%] Building NVCC (Device) object CMakeFiles/cuda_test.dir/cuda_test_generated_cuda_test.cu.o
   ***   nvcc fatal   : Path to libdevice library not specified
   ***   CMake Error at cuda_test_generated_cuda_test.cu.o.cmake:275 (message):
   ***     Error generating file
   ***     /home/peshmerge/Downloads/dlib-19.10/build/temp.linux-x86_64-3.5/dlib_build/cuda_test_build/CMakeFiles/cuda_test.dir//./cuda_test_generated_cuda_test.cu.o
   ***   
   ***   
   ***   CMakeFiles/cuda_test.dir/build.make:63: recipe for target 'CMakeFiles/cuda_test.dir/cuda_test_generated_cuda_test.cu.o' failed
   ***   make[2]: *** [CMakeFiles/cuda_test.dir/cuda_test_generated_cuda_test.cu.o] Error 1
   ***   CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/cuda_test.dir/all' failed
   ***   make[1]: *** [CMakeFiles/cuda_test.dir/all] Error 2
   ***   Makefile:83: recipe for target 'all' failed
   ***   make: *** [all] Error 2
   ***   
-- *****************************************************************************************************************
-- Found OpenMP_C: -fopenmp (found version "4.0") 
-- Found OpenMP_CXX: -fopenmp (found version "4.0") 
-- Found OpenMP: TRUE (found version "4.0")  
-- Disabling CUDA support for dlib.  DLIB WILL NOT USE CUDA
-- C++11 activated.
-- Found Python with installed numpy package
-- Numpy include path '/usr/lib/python3/dist-packages/numpy/core/include'
-- Performing Test HAS_FLTO
-- Performing Test HAS_FLTO - Success
-- LTO enabled
-- Configuring done
-- Generating done
-- Build files have been written to: /home/peshmerge/Downloads/dlib-19.10/build/temp.linux-x86_64-3.5
Invoking CMake build: 'cmake --build . --config Release -- -j8'
Scanning dependencies of target dlib
[  1%] Building CXX object dlib_build/CMakeFiles/dlib.dir/base64/base64_kernel_1.cpp.o
[  2%] Building CXX object dlib_build/CMakeFiles/dlib.dir/bigint/bigint_kernel_1.cpp.o
[  3%] Building CXX object dlib_build/CMakeFiles/dlib.dir/bigint/bigint_kernel_2.cpp.o
[  4%] Building CXX object dlib_build/CMakeFiles/dlib.dir/bit_stream/bit_stream_kernel_1.cpp.o
[  6%] Building CXX object dlib_build/CMakeFiles/dlib.dir/entropy_decoder/entropy_decoder_kernel_1.cpp.o
[  7%] Building CXX object dlib_build/CMakeFiles/dlib.dir/entropy_decoder/entropy_decoder_kernel_2.cpp.o
[  8%] Building CXX object dlib_build/CMakeFiles/dlib.dir/entropy_encoder/entropy_encoder_kernel_1.cpp.o
[  9%] Building CXX object dlib_build/CMakeFiles/dlib.dir/entropy_encoder/entropy_encoder_kernel_2.cpp.o
[ 11%] Building CXX object dlib_build/CMakeFiles/dlib.dir/md5/md5_kernel_1.cpp.o
[ 12%] Building CXX object dlib_build/CMakeFiles/dlib.dir/tokenizer/tokenizer_kernel_1.cpp.o
[ 13%] Building CXX object dlib_build/CMakeFiles/dlib.dir/unicode/unicode.cpp.o
[ 14%] Building CXX object dlib_build/CMakeFiles/dlib.dir/data_io/image_dataset_metadata.cpp.o
[ 16%] Building CXX object dlib_build/CMakeFiles/dlib.dir/data_io/mnist.cpp.o
[ 17%] Building CXX object dlib_build/CMakeFiles/dlib.dir/global_optimization/global_function_search.cpp.o
[ 18%] Building CXX object dlib_build/CMakeFiles/dlib.dir/filtering/kalman_filter.cpp.o
[ 19%] Building CXX object dlib_build/CMakeFiles/dlib.dir/test_for_odr_violations.cpp.o
[ 20%] Building CXX object dlib_build/CMakeFiles/dlib.dir/sockets/sockets_kernel_1.cpp.o
[ 22%] Building CXX object dlib_build/CMakeFiles/dlib.dir/bsp/bsp.cpp.o
[ 23%] Building CXX object dlib_build/CMakeFiles/dlib.dir/dir_nav/dir_nav_kernel_1.cpp.o
[ 24%] Building CXX object dlib_build/CMakeFiles/dlib.dir/dir_nav/dir_nav_kernel_2.cpp.o
[ 25%] Building CXX object dlib_build/CMakeFiles/dlib.dir/dir_nav/dir_nav_extensions.cpp.o
[ 27%] Building CXX object dlib_build/CMakeFiles/dlib.dir/linker/linker_kernel_1.cpp.o
[ 28%] Building CXX object dlib_build/CMakeFiles/dlib.dir/logger/extra_logger_headers.cpp.o
[ 29%] Building CXX object dlib_build/CMakeFiles/dlib.dir/logger/logger_kernel_1.cpp.o
[ 30%] Building CXX object dlib_build/CMakeFiles/dlib.dir/logger/logger_config_file.cpp.o
[ 32%] Building CXX object dlib_build/CMakeFiles/dlib.dir/misc_api/misc_api_kernel_1.cpp.o
[ 33%] Building CXX object dlib_build/CMakeFiles/dlib.dir/misc_api/misc_api_kernel_2.cpp.o
[ 34%] Building CXX object dlib_build/CMakeFiles/dlib.dir/sockets/sockets_extensions.cpp.o
[ 35%] Building CXX object dlib_build/CMakeFiles/dlib.dir/sockets/sockets_kernel_2.cpp.o
[ 37%] Building CXX object dlib_build/CMakeFiles/dlib.dir/sockstreambuf/sockstreambuf.cpp.o
[ 38%] Building CXX object dlib_build/CMakeFiles/dlib.dir/sockstreambuf/sockstreambuf_unbuffered.cpp.o
[ 39%] Building CXX object dlib_build/CMakeFiles/dlib.dir/server/server_kernel.cpp.o
[ 40%] Building CXX object dlib_build/CMakeFiles/dlib.dir/server/server_iostream.cpp.o
[ 41%] Building CXX object dlib_build/CMakeFiles/dlib.dir/server/server_http.cpp.o
[ 43%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/multithreaded_object_extension.cpp.o
[ 44%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/threaded_object_extension.cpp.o
[ 45%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/threads_kernel_1.cpp.o
[ 46%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/threads_kernel_2.cpp.o
[ 48%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/threads_kernel_shared.cpp.o
[ 49%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/thread_pool_extension.cpp.o
[ 50%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/async.cpp.o
[ 51%] Building CXX object dlib_build/CMakeFiles/dlib.dir/timer/timer.cpp.o
[ 53%] Building CXX object dlib_build/CMakeFiles/dlib.dir/stack_trace.cpp.o
[ 54%] Building CXX object dlib_build/CMakeFiles/dlib.dir/dnn/cpu_dlib.cpp.o
[ 55%] Building CXX object dlib_build/CMakeFiles/dlib.dir/dnn/tensor_tools.cpp.o
[ 56%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_widgets/fonts.cpp.o
[ 58%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_widgets/widgets.cpp.o
[ 59%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_widgets/drawable.cpp.o
[ 60%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_widgets/canvas_drawing.cpp.o
[ 61%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_widgets/style.cpp.o
[ 62%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_widgets/base_widgets.cpp.o
[ 64%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_core/gui_core_kernel_1.cpp.o
[ 65%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_core/gui_core_kernel_2.cpp.o
[ 66%] Building CXX object dlib_build/CMakeFiles/dlib.dir/image_loader/png_loader.cpp.o
[ 67%] Building CXX object dlib_build/CMakeFiles/dlib.dir/image_saver/save_png.cpp.o
[ 69%] Building CXX object dlib_build/CMakeFiles/dlib.dir/image_loader/jpeg_loader.cpp.o
[ 70%] Building CXX object dlib_build/CMakeFiles/dlib.dir/image_saver/save_jpeg.cpp.o
[ 71%] Linking CXX static library libdlib.a
[ 71%] Built target dlib
Scanning dependencies of target dlib_python
[ 72%] Building CXX object CMakeFiles/dlib_python.dir/src/dlib.cpp.o
[ 74%] Building CXX object CMakeFiles/dlib_python.dir/src/matrix.cpp.o
[ 75%] Building CXX object CMakeFiles/dlib_python.dir/src/vector.cpp.o
[ 76%] Building CXX object CMakeFiles/dlib_python.dir/src/svm_c_trainer.cpp.o
[ 77%] Building CXX object CMakeFiles/dlib_python.dir/src/svm_rank_trainer.cpp.o
[ 79%] Building CXX object CMakeFiles/dlib_python.dir/src/decision_functions.cpp.o
[ 80%] Building CXX object CMakeFiles/dlib_python.dir/src/other.cpp.o
[ 81%] Building CXX object CMakeFiles/dlib_python.dir/src/basic.cpp.o
[ 82%] Building CXX object CMakeFiles/dlib_python.dir/src/cca.cpp.o
[ 83%] Building CXX object CMakeFiles/dlib_python.dir/src/sequence_segmenter.cpp.o
[ 85%] Building CXX object CMakeFiles/dlib_python.dir/src/svm_struct.cpp.o
[ 86%] Building CXX object CMakeFiles/dlib_python.dir/src/image.cpp.o
[ 87%] Building CXX object CMakeFiles/dlib_python.dir/src/rectangles.cpp.o
[ 88%] Building CXX object CMakeFiles/dlib_python.dir/src/object_detection.cpp.o
[ 90%] Building CXX object CMakeFiles/dlib_python.dir/src/shape_predictor.cpp.o
[ 91%] Building CXX object CMakeFiles/dlib_python.dir/src/correlation_tracker.cpp.o
[ 92%] Building CXX object CMakeFiles/dlib_python.dir/src/face_recognition.cpp.o
[ 93%] Building CXX object CMakeFiles/dlib_python.dir/src/cnn_face_detector.cpp.o
[ 95%] Building CXX object CMakeFiles/dlib_python.dir/src/global_optimization.cpp.o
[ 96%] Building CXX object CMakeFiles/dlib_python.dir/src/image_dataset_metadata.cpp.o
[ 97%] Building CXX object CMakeFiles/dlib_python.dir/src/numpy_returns.cpp.o
[ 98%] Building CXX object CMakeFiles/dlib_python.dir/src/gui.cpp.o
[100%] Linking CXX shared module /home/peshmerge/Downloads/dlib-19.10/build/lib.linux-x86_64-3.5/dlib.cpython-35m-x86_64-linux-gnu.so
[100%] Built target dlib_python
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
copying build/lib.linux-x86_64-3.5/dlib.cpython-35m-x86_64-linux-gnu.so -> build/bdist.linux-x86_64/egg
creating stub loader for dlib.cpython-35m-x86_64-linux-gnu.so
byte-compiling build/bdist.linux-x86_64/egg/dlib.py to dlib.cpython-35.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying dlib.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying dlib.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying dlib.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying dlib.egg-info/not-zip-safe -> build/bdist.linux-x86_64/egg/EGG-INFO
copying dlib.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt
creating dist
creating 'dist/dlib-19.10.0-py3.5-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing dlib-19.10.0-py3.5-linux-x86_64.egg
creating /usr/local/lib/python3.5/dist-packages/dlib-19.10.0-py3.5-linux-x86_64.egg
Extracting dlib-19.10.0-py3.5-linux-x86_64.egg to /usr/local/lib/python3.5/dist-packages
Adding dlib 19.10.0 to easy-install.pth file

Installed /usr/local/lib/python3.5/dist-packages/dlib-19.10.0-py3.5-linux-x86_64.egg
Processing dependencies for dlib==19.10.0
Finished processing dependencies for dlib==19.10.0

如果我使用选项 --yes USE_AVX_INSTRUCTIONS 运行 setup.py,我不会收到任何关于使用 CUDA 的消息。我这样运行它:

sudo python3.5 setup.py install --yes USE_AVX_INSTRUCTIONS

我不知道当我使用那个标志时它会导致什么,我不确定它是否禁用使用 CUDA 编译它!

有没有人知道为什么它在构建 Dlib 时成功找到 CUDA 而在我想编译 Dlib 的 Python 接口(interface)时却失败了?

我已尝试按照此处的建议使用 Cmake 编译 Dlib 的 Python 接口(interface) Installation guide by dlib.net ,但它也失败了!

编辑1

我运行 sudo python3.5 setup.py install --clean

我得到了:

running install
Checking .pth file support in /usr/local/lib/python3.5/dist-packages/
/usr/bin/py -E -c pass
TEST PASSED: /usr/local/lib/python3.5/dist-packages/ appears to support .pth files
running bdist_egg
running egg_info
writing dependency_links to dlib.egg-info/dependency_links.txt
writing dlib.egg-info/PKG-INFO
writing top-level names to dlib.egg-info/top_level.txt
package init file 'dlib/__init__.py' not found (or not a regular file)
reading manifest file 'dlib.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'dlib.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
running build_ext
Removing old directory /home/peshmerge/Downloads/dlib-19.10/build/temp.linux-x86_64-3.5
Invoking CMake setup: 'cmake /home/peshmerge/Downloads/dlib-19.10/tools/python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/peshmerge/Downloads/dlib-19.10/build/lib.linux-x86_64-3.5 -DPYTHON_EXECUTABLE=/usr/bin/py -DCMAKE_BUILD_TYPE=Release'
-- The C compiler identification is GNU 5.4.1
-- The CXX compiler identification is GNU 5.4.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: /usr/bin/py (found version "3.5.2") 
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.5m.so
-- Performing Test HAS_CPP14_FLAG
-- Performing Test HAS_CPP14_FLAG - Success
-- pybind11 v2.2.2
-- Enabling SSE4 instructions
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Found X11: /usr/lib/x86_64-linux-gnu/libX11.so
-- 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
-- Searching for BLAS and LAPACK
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") 
-- Checking for module 'cblas'
--   No package 'cblas' found
-- Checking for module 'lapack'
--   Found lapack, version 0.2.18
-- 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 OpenBLAS library
-- Looking for sgetrf_single
-- Looking for sgetrf_single - found
-- Using OpenBLAS's built in LAPACK
-- Looking for cblas_ddot
-- Looking for cblas_ddot - found
-- Looking for sgesv
-- Looking for sgesv - not found
-- Looking for sgesv_
-- Looking for sgesv_ - not found
-- Could NOT find CUDA (missing: CUDA_INCLUDE_DIRS CUDA_CUDART_LIBRARY) (found suitable version "9.1", minimum required is "7.5")
-- Disabling CUDA support for dlib.  DLIB WILL NOT USE CUDA
-- C++11 activated.
-- Found Python with installed numpy package
-- Numpy include path '/usr/lib/python3/dist-packages/numpy/core/include'
-- Performing Test HAS_FLTO
-- Performing Test HAS_FLTO - Success
-- LTO enabled
-- Configuring done
-- Generating done
-- Build files have been written to: /home/peshmerge/Downloads/dlib-19.10/build/temp.linux-x86_64-3.5
Invoking CMake build: 'cmake --build . --config Release -- -j8'
Scanning dependencies of target dlib

现在正在提示

-- Could NOT find CUDA (missing: CUDA_INCLUDE_DIRS CUDA_CUDART_LIBRARY) (found suitable version "9.1", minimum required is "7.5")

虽然在我的环境中定义了 CUDA_INCLUDE_DIRSCUDA_CUDART_LIBRARY

echo $CUDA_CUDART_LIBRARY && echo $CUDA_INCLUDE_DIRS
/usr/local/cuda-9.1/lib64/libcudart.so
/usr/local/cuda-9.1/include

EdIT2: 运行 python3.5 setup.py install --clean 没有 sudo 结果

running install
Checking .pth file support in /usr/local/lib/python3.5/dist-packages/
error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

    [Errno 13] Permission denied: '/usr/local/lib/python3.5/dist-packages/test-easy-install-7244.pth'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /usr/local/lib/python3.5/dist-packages/

Perhaps your account does not have write access to this directory?  If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account.  If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.

For information on other options, you may wish to consult the
documentation at:

  https://pythonhosted.org/setuptools/easy_install.html

Please make the appropriate changes for your system and try again.

编辑 3: 我已经使用 cmake 使用以下操作完成了 dlib 的编译:

mkdir build
cd build
cmake ..
cmake --build . --config Release
sudo make install
sudo ldconfig

最佳答案

使用 CUDA 为 Python 3.x 构建 DLIB Python 模块。

sudo python3 setup.py install --yes USE_AVX_INSTRUCTIONS --yes DLIB_USE_CUDA

注意:在构建 Python 模块之前不需要构建 CUDA。

关于python - 为什么我得到 "dlib isn' t going to use CUDA"when I compile dlib python interface,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49841147/

相关文章:

c++ - 使用 Dlib 进行地标检测

python - 使用 Luhn 算法验证信用卡号 Python

python - 为什么Python中导入的类属性没有改变?

python - 在 Python/PyCharm 中明确声明变量未使用

python - 是否可以在打印之前清理冗长的 python 正则表达式?

Python 3 - 如何在命令行窗口中创建打字效果

python - 在 Mac OSX 10.10 上为 python 安装 Dlib 时遇到问题

python - 为 Django 的日期输入设置添加一个值

python-3.x - 如何在Python-pptx中打印所有图表属性

c++ - 如何将 dlib 中的矩阵转换为 std::vector