使用CUDA toolkit 8.0安装openCV

时间:2017-04-02 21:48:27

标签: opencv cuda

我试图在Ubuntu 16.04上安装Opencv 3.2.0和Nvidia CUDA工具包8.0,但我无法将它们配置在一起。当我尝试使用两者创建项目时出现以下错误:

CMake Error at /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
    Could NOT find CUDA: Found unsuitable version "8.0", but required is exact
    version "7.5" (found /usr/local/cuda)
Call Stack (most recent call first):
    /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:386 (_FPHSA_FAILURE_MESSAGE)
    /usr/share/cmake-3.5/Modules/FindCUDA.cmake:949 (find_package_handle_standard_args)

    /usr/local/share/OpenCV/OpenCVConfig.cmake:86 (find_package)
    /usr/local/share/OpenCV/OpenCVConfig.cmake:105 (find_host_package)
CMakeLists.txt:10 (find_package)


-- Configuring incomplete, errors occurred!

我尝试过安装cuda toolkit 7.5,但我认为它与ubuntu 16.04不兼容。我现在真的很无能,我希望有人可以帮忙解决这个问题。 感谢

1 个答案:

答案 0 :(得分:1)

所以我通过管理安装toolkit 7.5解决了这个问题。我是这样做的:

  1. 更新了我的操作系统的nvidia驱动程序
  2. 下载cuda toolkit 7.5并将其解压缩到一个文件夹

    def parse(self, response):
        ...
    
        yield Request(url='myurl', callback=self.some_other_method)
    
    def some_other_method(self, response):
        ...
        # play with the response object of the request done to `myurl`
    
  3. 按Ctrl + Alt + F1进入虚拟控制台并关闭 lightdm服务

    $ mkdir ~/Downloads/NVIDIA_TOOLKIT
    $ cd ~/Downloads
    $ ./cuda_7.5.18_linux.run -extract=~/Downloads/NVIDIA_TOOLKIT;
    
  4. cd下载并安装提取的工具包和示例

    $ sudo service lightdm stop
    
  5. 在.bashrc文件中设置环境变量

    $ cd ~/Downloads/NVIDIA_TOOLKIT
    $ sudo ./cuda-linux64-rel-6.0.37-18176142.run
    $ sudo ./cuda-samples-linux-6.0.37-18176142.run 
    
  6. 重新启用lightdm服务

    $ PATH=/usr/local/cuda-7.5/bin
    $ LD_LIBRARY_PATH=/usr/local/cuda-7.5/lib64
    
  7. 重新启动,您应该可以使用nvcc编译器

  8. 对于openCV,您必须将gcc / g ++编译器降级到4.9,因为它与更高版本不兼容