在Linux中的多个平台上启用OpenCL?如何处理ICD文件?

时间:2016-04-30 05:37:10

标签: linux ubuntu opencl intel nvidia

详细

我需要安装哪些驱动程序/软件包才能在多个平台上启用OpenCL:CPU(英特尔),集成GPU(英特尔),专用GPU(NVIDIA)? 让所有平台运行OpenCL 1.2或更高版本

会很不错

我知道这可能只是一个简单的解决方案,也许只是正确的库/ SKD选择,但是我在使用一个平台工作时遇到了一些麻烦。

运行ubuntu 14.04:我的智能核心I5带有集成的英特尔显卡和专用的NVIDIA Geforce 710m主板。

我用过的资源

https://wiki.tiker.net/OpenCLHowTo
在这里(在Debian下)它告诉我我只需要:

  1. ICD加载器包:(您只需要其中一个)
  2. ICD包
  3. 标题包
  4. 我已经尝试了什么

    1. 已安装的CUDA7.5(对所有人都是)
      • 由于司机冲突导致黑屏
        • 通过卸载所有nvidia驱动程序并安装352
        • 解决
        • 仍然离开Cuda SDK安装
    2. 来自:How to make OpenCL work on 14.10 + Nvidia 331.89 drivers?
      • sudo apt-get install nvidia-331 nvidia-331-uvm nvidia-opencl-dev nvidia-modprobe
      • 这些软件包将我的驱动程序降级为331和340
    3. 同样来自:How to make OpenCL work on 14.10 + Nvidia 331.89 drivers?
      • 链接库:
        • sudo ln -s /usr/include/nvidia-352/GL /usr/local/include
        • sudo ln -s /usr/lib/x86_64-linux-gnu/libOpenCL.so.1 /usr/local/lib/libOpenCL.so
      • OpenCL 1.1 工作用于NVIDIA GPU
      • 无法获得OpenCL 1.2,因此决定卸载331和340并再次安装352
    4. 已安装352(再次)
      • OpenCL 1.1 停止工作用于NVIDIA GPU(但仍无效)
    5. 已安装英特尔opencl_runtime_14.2_x64_4.5.0.8.tgz

      • 创建了一个与intel ICD的简单链接:

        • sudo ln -s /opt/intel/opencl-1.2-4.5.0.8/etc/intel64.icd
      • OpenCL 1.2 工作用于CPU(并且仍然有效)

    6. 已安装clinfo sudo apt-get install clinfo

      • 仅检测到intel CPU平台
    7. 试图安装几个不同的NVIDIA软件包,让NVIDIA GPU再次运行,但没有运气
    8. 已安装的软件包和一些信息:

      供应商的ICD?

      ls -l /etc/OpenCL/vendors/
      total 4
      -rw-r--r-- 1 root root 15 Out 22  2015 Altera.icd
      lrwxrwxrwx 1 root root 45 Abr 28 13:48 intel64.icd -> /opt/intel/opencl-1.2-4.5.0.8/etc/intel64.icd
      

      请注意缺少的nvidia.icd

      CL和GL - GL有一个有效的链接......现在是IN RED

      ls -l /usr/local/include
      total 4
      lrwxrwxrwx 1 root root   31 Abr 28 12:48 CL -> /usr/local/cuda-7.5/include/CL/
      lrwxrwxrwx 1 root root   26 Abr 27 11:44 GL -> /usr/include/nvidia-352/GL (IN RED COLOR - folder doesn't exist anymore)
      

      .so文件

      ls -l /usr/local/lib/ | grep CL
      lrwxrwxrwx 1 root root    40 Abr 27 11:45 libOpenCL.so -> /usr/lib/x86_64-linux-gnu/libOpenCL.so.1
      

      已安装的软件包

      dpkg --get-selections | grep nvidia
      nvidia-340                  deinstall
      nvidia-352                  install
      nvidia-libopencl1-340               deinstall
      nvidia-libopencl1-340-updates           deinstall
      nvidia-libopencl1-352               deinstall
      nvidia-libopencl1-352-updates           install
      nvidia-modprobe                 install
      nvidia-opencl-icd-340               deinstall
      nvidia-opencl-icd-352               deinstall
      nvidia-prime                    install
      nvidia-settings                 install
      
      
      dpkg --get-selections | grep opencl
      nvidia-libopencl1-340               deinstall
      nvidia-libopencl1-340-updates           deinstall
      nvidia-libopencl1-352               deinstall
      nvidia-libopencl1-352-updates           install
      nvidia-opencl-icd-340               deinstall
      nvidia-opencl-icd-352               deinstall
      ocl-icd-libopencl1:amd64            deinstall
      ocl-icd-libopencl1:i386             deinstall
      opencl-headers                  install
      unity-scope-openclipart             install
      

      clinfo

      clinfo 
      Number of platforms:                 1
        Platform Profile:              FULL_PROFILE
        Platform Version:              OpenCL 1.2 LINUX
        Platform Name:                 Intel(R) OpenCL
        Platform Vendor:               Intel(R) Corporation
        Platform Extensions:               cl_khr_icd cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_spir cl_intel_exec_by_local_thread cl_khr_depth_images cl_khr_3d_image_writes cl_khr_fp64 
      
      
        Platform Name:                 Intel(R) OpenCL
      Number of devices:               1
        Device Type:                   CL_DEVICE_TYPE_CPU
        Device ID:                     32902
        Max compute units:                 4
        Max work items dimensions:             3
          Max work items[0]:               8192
          Max work items[1]:               8192
          Max work items[2]:               8192
        Max work group size:               8192
        Preferred vector width char:           1
        Preferred vector width short:          1
        Preferred vector width int:            1
        Preferred vector width long:           1
        Preferred vector width float:          1
        Preferred vector width double:         1
        Native vector width char:          16
        Native vector width short:             8
        Native vector width int:           4
        Native vector width long:          2
        Native vector width float:             8
        Native vector width double:            4
        Max clock frequency:               1800Mhz
        Address bits:                  64
        Max memory allocation:             2040185856
        Image support:                 Yes
        Max number of images read arguments:       480
        Max number of images write arguments:      480
        Max image 2D width:                16384
        Max image 2D height:               16384
        Max image 3D width:                2048
        Max image 3D height:               2048
        Max image 3D depth:                2048
        Max samplers within kernel:            480
        Max size of kernel argument:           3840
        Alignment (bits) of base address:      1024
        Minimum alignment (bytes) for any datatype:    128
        Single precision floating point capability
          Denorms:                     Yes
          Quiet NaNs:                  Yes
          Round to nearest even:           Yes
          Round to zero:               No
          Round to +ve and infinity:           No
          IEEE754-2008 fused multiply-add:         No
        Cache type:                    Read/Write
        Cache line size:               64
        Cache size:                    262144
        Global memory size:                8160743424
        Constant buffer size:              131072
        Max number of constant args:           480
        Local memory type:                 Global
        Local memory size:                 32768
        Error correction support:          0
        Unified memory for Host and Device:        1
        Profiling timer resolution:            1
        Device endianess:              Little
        Available:                     Yes
        Compiler available:                Yes
        Execution capabilities:                
          Execute OpenCL kernels:          Yes
          Execute native function:             Yes
        Queue properties:              
          Out-of-Order:                Yes
          Profiling :                  Yes
        Platform ID:                   0x1659390
        Name:                             Intel(R) Core(TM) i5-3337U CPU @ 1.80GHz
        Vendor:                    Intel(R) Corporation
        Device OpenCL C version:           OpenCL C 1.2 
        Driver version:                1.2.0.8
        Profile:                   FULL_PROFILE
        Version:                   OpenCL 1.2 (Build 8)
        Extensions:                    cl_khr_icd cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_spir cl_intel_exec_by_local_thread cl_khr_depth_images cl_khr_3d_image_writes cl_khr_fp64 
      

      所以...

      如何让NVIDIA gpu也显示为OPENCL 1.2(或更高版本)平台?集成的intel图形怎么样?
      AMD图书馆可以使用我的硬件吗? 为什么大多数nvidia软件包都标记为deinstall

1 个答案:

答案 0 :(得分:1)

如前所述,有三件事是必要的:

来自https://wiki.tiker.net/OpenCLHowTo

  • ICD加载器包:(您只需要其中一个)
  • ICD包
  • 标题包

因此对于Intel CPU和NVIDIA GPU

  • ICD加载程序包
    • OCL-ICD-libopencl1
  • ICD 的套餐
  • 标题的包
    • 的OpenCL报头

但是,要使其正常运行,必须确保通过dpkg --get-selections | grep opencl

将包标记为安装
sudo apt-get install --reinstall nvidia-opencl-icd-352 opencl-headers ocl-icd-libopencl1

最重要的是,您必须确保intel64.icd和nvidia.icd位于/etc/OpenCL/vendorsls -l /etc/OpenCL/vendors)。

那就是说,我必须将intel64.icd与:

联系起来
cd /etc/OpenCL/vendors/
sudo ln -s /opt/intel/opencl-1.2-X.X.X.X/etc/intel64.icd

并且,由于nvidia.icd不在文件夹中(即使安装了正确的软件包之后),我不得不提取它并手动从deb软件包中移动

dpkg -x /var/cache/apt/archives/nvidia-opencl-icd-352_352.63-0ubuntu0.14.04.1_amd64.deb ~/tempfolder
sudo mv ~/tempfolder/etc/OpenCL/vendors/nvidia.icd /etc/OpenCL/vendors/nvidia.icd
rm -r ~/tempfolder

最后,确保nvidia是活动GPU

sudo prime-select nvidia
sudo reboot -r now

安装并执行clinfo,两个平台都应该显示。

clinfo 
Number of platforms:                 2
  Platform Profile:              FULL_PROFILE
  Platform Version:              OpenCL 1.2 CUDA 7.5.23
  Platform Name:                 NVIDIA CUDA
  Platform Vendor:               NVIDIA Corporation
  Platform Extensions:               cl_khr_byte_addressable_store cl_khr_icd cl_khr_gl_sharing cl_nv_compiler_options cl_nv_device_attribute_query cl_nv_pragma_unroll cl_nv_copy_opts 
  Platform Profile:              FULL_PROFILE
  Platform Version:              OpenCL 1.2 LINUX
  Platform Name:                 Intel(R) OpenCL
  Platform Vendor:               Intel(R) Corporation
  Platform Extensions:               cl_khr_icd cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_spir cl_intel_exec_by_local_thread cl_khr_depth_images cl_khr_3d_image_writes cl_khr_fp64 
相关问题