安装具有GPU支持的dlib时发生错误

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安装具有GPU支持的dlib时发生错误相关的知识,希望对你有一定的参考价值。

我已经安装了Cmake,visual studio 2019和anaconda。我正在尝试在gpu支持中使用Dlib。但是每次我尝试安装它时,运行python setup.py都会出现以下错误。我想将Dlib与GPU(CUDA)支持一起使用。


   C:Usersyugahanganaconda3Libsite-packagesdlib-master>python setup.py install --set 
    USE_AVX_INSTRUCTIONS --set DLIB_USE_CUDA 
    running install 
    running bdist_egg 
    running egg_info 
    writing dlib.egg-infoPKG-INFO 
    writing dependency_links to dlib.egg-infodependency_links.txt 
    writing top-level names to dlib.egg-info	op_level.txt 
    package init file 'dlib\__init__.py' not found (or not a regular file) 
    reading manifest file 'dlib.egg-infoSOURCES.txt' 

    reading manifest template 'MANIFEST.in' 
    no previously-included directories found matching 'toolspythonuild*' 
    writing manifest file 'dlib.egg-infoSOURCES.txt' 
    installing library code to builddist.win-amd64egg 
    running install_lib 
    running build_py 
    running build_ext 
    Building extension for Python 3.7.6 (default, Jan  8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)]
    Invoking CMake setup: 'cmake C:Usersyugahanganaconda3Libsite-packagesdlib-master	oolspython -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:Usersyugahanganaconda3Libsite-packagesdlib-masteruildlib.win-amd64-3.7 -DPYTHON_EXECUTABLE=C:UsersyugahangAnaconda3python.exe -DUSE_AVX_INSTRUCTIONS -DDLIB_USE_CUDA -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:Usersyugahanganaconda3Libsite-packagesdlib-masteruildlib.win-amd64-3.7 -A x64' 
    CMake Error: Parse error in command line argument: -DUSE_AVX_INSTRUCTIONS 
    Should be: VAR:type=value 

    CMake Error: Problem processing arguments. Aborting. 


    Traceback (most recent call last):
      File "setup.py", line 261, in 
        'Topic :: Software Development',
      File "C:UsersyugahangAnaconda3libsite-packagessetuptools\__init__.py", line 144, in setup
        return distutils.core.setup(**attrs)
      File "C:UsersyugahangAnaconda3libdistutilscore.py", line 148, in setup
        dist.run_commands()
      File "C:UsersyugahangAnaconda3libdistutilsdist.py", line 966, in run_commands
        self.run_command(cmd)
      File "C:UsersyugahangAnaconda3libdistutilsdist.py", line 985, in run_commands`   `
        cmd_obj.run()
      File "C:UsersyugahangAnaconda3libsite-packagessetuptoolscommandinstall.py", line 67, in run
        self.do_egg_install()
      File "C:UsersyugahangAnaconda3libsite-packagessetuptoolscommandinstall.py", line 109, in do_egg_install
        self.run_command('bdist_egg')
      File "C:UsersyugahangAnaconda3libdistutilscmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:UsersyugahangAnaconda3libdistutilsdist.py", line 985, in run_command
        cmd_obj.run()
      File "C:UsersyugahangAnaconda3libsite-packagessetuptoolscommanddist_egg.py", line 172, in run
        cmd = self.call_command('install_lib', warn_dir=0)
      File "C:UsersyugahangAnaconda3libsite-packagessetuptoolscommanddist_egg.py", line 158, in call_command
        self.run_command(cmdname)
      File "C:UsersyugahangAnaconda3libdistutilscmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:UsersyugahangAnaconda3libdistutilsdist.py", line 985, in run_command
        cmd_obj.run()
      File "C:UsersyugahangAnaconda3libsite-packagessetuptoolscommandinstall_lib.py", line 11, in run
        self.build()
      File "C:UsersyugahangAnaconda3libdistutilscommandinstall_lib.py", line 107, in build
        self.run_command('build_ext')`
      File "C:UsersyugahangAnaconda3libdistutilscmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:UsersyugahangAnaconda3libdistutilsdist.py", line 985, in run_command
        cmd_obj.run()
      File "setup.py", line 135, in run`enter code here`
        self.build_extension(ext)
      File "setup.py", line 172, in build_extension
        subprocess.check_call(cmake_setup, cwd=build_folder)
      File "C:UsersyugahangAnaconda3libsubprocess.py", line 363, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['cmake', 'C:\Users\yugahang\anaconda3\Lib\site-packages\dlib-master\tools\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\yugahang\anaconda3\Lib\site-packages\dlib-master\build\lib.win-amd64-3.7', '-DPYTHON_EXECUTABLE=C:\Users\yugahang\Anaconda3\python.exe', '-DUSE_AVX_INSTRUCTIONS', '-DDLIB_USE_CUDA', '-`enter code here`DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\yugahang\anaconda3\Lib\site-packages\dlib-master\build\lib.win-amd64-3.7', '-A', 'x64']' returned non-zero exit status 1.

有没有解决此问题的方法。首先,我想知道是什么导致了此问题。

答案

--set的参数setup.py应该采用格式

--set <variable>=<value>

这将cmake参数转换为-D<variable>=<value>,完全适合cmake synopsis

例如代替

--set USE_AVX_INSTRUCTIONS

使用

--set USE_AVX_INSTRUCTIONS=ON

--no的参数setup.py没有分配(=<value>)部分,因为

--no <variable>

将自动转换为cmake参数-D<variable>=no

以上是关于安装具有GPU支持的dlib时发生错误的主要内容,如果未能解决你的问题,请参考以下文章

Dlib(支持 GPU)不能正常工作,不确定?

如何检查 dlib 是不是正在使用 GPU?

导入具有GPU支持的TensorFlow时DLL加载失败

dlib 不使用 CUDA

如何安装dlib gpu版本

Win10 安装dlib GPU详解。