尝试在启用GPU的情况下安装yolo34py时收到错误“OpenCV 4.x+需要启用的C++11支持”

2024-09-29 08:25:05 发布

您现在位置:Python中文网/ 问答频道 /正文

根据https://github.com/madhawav/YOLO3-4-Py上的说明从源代码进行安装

我已经找到了“OpenCV 4.x+需要启用C++11支持”错误的解决方案,该错误表示我应该在Makefile中的g++编译器命令中添加-std=C++11标志。但是,我在克隆的git存储库中没有看到Makefile。有没有办法通过setup.py文件添加标志?或者是其他什么原因导致了这个错误

从/src运行pip install .时的终端输出:

   Defaulting to user installation because normal site-packages is not writeable
Processing /home/justin/YOLO3-4-Py/src
  DEPRECATION: A future pip version will change local packages to be built in-place without first copying to a temporary directory. We recommend you use --use-feature=in-tree-build to test your packages with this new behavior before it becomes the default.
   pip 21.3 will remove support for this functionality. You can find discussion regarding this at https://github.com/pypa/pip/issues/7555.
Requirement already satisfied: cython>=0.27 in /home/justin/.local/lib/python3.6/site-packages (from yolo34py-gpu==0.2) (0.29.23)
Requirement already satisfied: requests in /usr/lib/python3/dist-packages (from yolo34py-gpu==0.2) (2.18.4)
Requirement already satisfied: numpy in /home/justin/.local/lib/python3.6/site-packages (from yolo34py-gpu==0.2) (1.19.5)
Building wheels for collected packages: yolo34py-gpu
  Building wheel for yolo34py-gpu (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-ojoxvm8t/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-ojoxvm8t/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-64ftn5bp
       cwd: /tmp/pip-req-build-ojoxvm8t/
  Complete output (39 lines):
  INFO:root:Compiling wrapper with gpu
  command : pkg-config --cflags opencv
  WTF2
  
  ['-I/usr/include/opencv', '-I/usr/include/opencv2']
  
  INFO:root:Compiling wrapper with OpenCV
  INFO:root:Darknet will be downloaded from 'https://github.com/madhawav/darknet/archive/yolo34py-intergration-v2.zip'
  KNN
  
  ['-std=c++11', '-I/usr/include/python3.6m', '-I/usr/include/python3.6m', '-Wno-unused-result', '-Wsign-compare', '-g', '-fdebug-prefix-map=/build/python3.6-XJChoo/python3.6-3.6.9=.', '-specs=/usr/share/dpkg/no-pie-compile.specs', '-fstack-protector', '-Wformat', '-Werror=format-security', '-DNDEBUG', '-g', '-fwrapv', '-O3', '-Wall']
  command : pkg-config --cflags opencv
  WTF2
  
  ['-I/usr/include/opencv', '-I/usr/include/opencv2']
  
  running bdist_wheel
  running build
  /usr/lib/python3/dist-packages/requests/__init__.py:80: RequestsDependencyWarning: urllib3 (1.26.6) or chardet (3.0.4) doesn't match a supported version!
    RequestsDependencyWarning)
  INFO:root:Temp Path: /tmp/darknet
  INFO:root:Downloading darknet
  INFO:root:Extracting darknet
  INFO:root:Building darknet
  INFO:root:b'gcc -Iinclude/ -Isrc/ -DOPENCV `pkg-config --cflags opencv`  -DGPU -I/usr/local/cuda/include/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -DOPENCV -DGPU -c ./src/gemm.c -o obj/gemm.o'
  In file included from /usr/include/opencv/opencv2/core/types_c.h:82:0,
                   from /usr/include/opencv/opencv2/core/core_c.h:48,
                   from /usr/include/opencv/opencv2/highgui/highgui_c.h:45,
                   from include/darknet.h:25,
                   from ./src/utils.h:5,
                   from ./src/gemm.c:2:
  /usr/include/opencv/opencv2/core/cvdef.h:690:4: error: #error "OpenCV 4.x+ requires enabled C++11 support"
   #  error "OpenCV 4.x+ requires enabled C++11 support"
      ^~~~~
  compilation terminated due to -Wfatal-errors.
  make: *** [obj/gemm.o] Error 1
  INFO:root:b"Makefile:85: recipe for target 'obj/gemm.o' failed"
  INFO:root:Moving to /tmp/pip-req-build-ojoxvm8t/__libdarknet/libdarknet.so
  error: [Errno 2] No such file or directory: '/tmp/darknet/darknet-yolo34py-intergration-v2/libdarknet.so'
  ----------------------------------------
  ERROR: Failed building wheel for yolo34py-gpu
  Running setup.py clean for yolo34py-gpu
Failed to build yolo34py-gpu
Installing collected packages: yolo34py-gpu
  Attempting uninstall: yolo34py-gpu
    Found existing installation: yolo34py-gpu 0.2
    Uninstalling yolo34py-gpu-0.2:
      Successfully uninstalled yolo34py-gpu-0.2
    Running setup.py install for yolo34py-gpu ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-ojoxvm8t/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-ojoxvm8t/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-ngsghqbh/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/justin/.local/include/python3.6m/yolo34py-gpu
         cwd: /tmp/pip-req-build-ojoxvm8t/
    Complete output (39 lines):
    INFO:root:Compiling wrapper with gpu
    command : pkg-config --cflags opencv
    WTF2
    
    ['-I/usr/include/opencv', '-I/usr/include/opencv2']
    
    INFO:root:Compiling wrapper with OpenCV
    INFO:root:Darknet will be downloaded from 'https://github.com/madhawav/darknet/archive/yolo34py-intergration-v2.zip'
    KNN
    
    ['-std=c++11', '-I/usr/include/python3.6m', '-I/usr/include/python3.6m', '-Wno-unused-result', '-Wsign-compare', '-g', '-fdebug-prefix-map=/build/python3.6-XJChoo/python3.6-3.6.9=.', '-specs=/usr/share/dpkg/no-pie-compile.specs', '-fstack-protector', '-Wformat', '-Werror=format-security', '-DNDEBUG', '-g', '-fwrapv', '-O3', '-Wall']
    command : pkg-config --cflags opencv
    WTF2
    
    ['-I/usr/include/opencv', '-I/usr/include/opencv2']
    
    running install
    running build
    /usr/lib/python3/dist-packages/requests/__init__.py:80: RequestsDependencyWarning: urllib3 (1.26.6) or chardet (3.0.4) doesn't match a supported version!
      RequestsDependencyWarning)
    INFO:root:Temp Path: /tmp/darknet
    INFO:root:Downloading darknet
    INFO:root:Extracting darknet
    INFO:root:Building darknet
    INFO:root:b'gcc -Iinclude/ -Isrc/ -DOPENCV `pkg-config --cflags opencv`  -DGPU -I/usr/local/cuda/include/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -DOPENCV -DGPU -c ./src/gemm.c -o obj/gemm.o'
    In file included from /usr/include/opencv/opencv2/core/types_c.h:82:0,
                     from /usr/include/opencv/opencv2/core/core_c.h:48,
                     from /usr/include/opencv/opencv2/highgui/highgui_c.h:45,
                     from include/darknet.h:25,
                     from ./src/utils.h:5,
                     from ./src/gemm.c:2:
    /usr/include/opencv/opencv2/core/cvdef.h:690:4: error: #error "OpenCV 4.x+ requires enabled C++11 support"
     #  error "OpenCV 4.x+ requires enabled C++11 support"
        ^~~~~
    compilation terminated due to -Wfatal-errors.
    make: *** [obj/gemm.o] Error 1
    INFO:root:b"Makefile:85: recipe for target 'obj/gemm.o' failed"
    INFO:root:Moving to /tmp/pip-req-build-ojoxvm8t/__libdarknet/libdarknet.so
    error: [Errno 2] No such file or directory: '/tmp/darknet/darknet-yolo34py-intergration-v2/libdarknet.so'
    ----------------------------------------
  Rolling back uninstall of yolo34py-gpu
  Moving to /home/justin/.local/lib/python3.6/site-packages/__libdarknet/
   from /home/justin/.local/lib/python3.6/site-packages/~_libdarknet
  Moving to /home/justin/.local/lib/python3.6/site-packages/pydarknet.cpython-36m-aarch64-linux-gnu.so
   from /tmp/pip-uninstall-iuo7ef9g/pydarknet.cpython-36m-aarch64-linux-gnu.so
  Moving to /home/justin/.local/lib/python3.6/site-packages/yolo34py_gpu-0.2.dist-info/
   from /home/justin/.local/lib/python3.6/site-packages/~olo34py_gpu-0.2.dist-info
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-ojoxvm8t/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-ojoxvm8t/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-ngsghqbh/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/justin/.local/include/python3.6m/yolo34py-gpu Check the logs for full command output.

Tags: pipfrombuildinfogpuincludepackagesusr