安装环境

$ cd /opt/intel/openvino_2022/install_dependencies
$ sudo -E ./install_NEO_OCL_driver.sh
如果这里因下载deb慢,而改用手动下载并安装。之后需要修改脚本跳过`check_current_driver( )`执行之后操作以便安装其它依赖。

/opt/intel/openvino_2022/install_dependencies

Adding aibox to the video group...
Adding aibox to the render group...

Installation completed successfully.

Next steps:
Add OpenCL users to the video and render group: 'sudo usermod -a -G video,render USERNAME'
   e.g. if the user running OpenCL host applications is foo, run: sudo usermod -a -G video,render foo
   Current user has been already added to the video and render group

If you use 8th Generation Intel® Core™ processor, add:
   i915.alpha_support=1
   to the 4.14 kernel command line, in order to enable OpenCL functionality for this platform.

$ sudo usermod -a -G video,render aibox

$ sudo apt install clinfo intel-opencl-icd
$ clinfo

排查显卡问题/dev/dri No such file or directory

$ sudo lspci -nn -v -s 00:02.0
00:02.0 VGA compatible controller [0300]: Intel Corporation Device [8086:4555] (rev 01) (prog-if 00 [VGA controller])
        DeviceName: Onboard - Video
        Subsystem: Intel Corporation Device [8086:7270]
        Flags: bus master, fast devsel, latency 0, IRQ 255
        Memory at 6000000000 (64-bit, non-prefetchable) [size=16M]
        Memory at 4000000000 (64-bit, prefetchable) [size=256M]
        I/O ports at 3000 [size=64]
        Expansion ROM at 000c0000 [virtual] [disabled] [size=128K]
        Capabilities: [40] Vendor Specific Information: Len=0c <?>
        Capabilities: [70] Express Root Complex Integrated Endpoint, MSI 00
        Capabilities: [ac] MSI: Enable- Count=1/1 Maskable+ 64bit-
        Capabilities: [d0] Power Management version 2
        Capabilities: [100] Process Address Space ID (PASID)
        Capabilities: [200] Address Translation Service (ATS)
        Capabilities: [300] Page Request Interface (PRI)

$ lsmod |  grep -i i915
i915                 1994752  0
drm_kms_helper        184320  1 i915
i2c_algo_bit           16384  1 i915
drm                   491520  2 drm_kms_helper,i915
video                  49152  1 i915

$ sudo apt install vainfo
$ vainfo
error: can't connect to X server!
error: failed to initialize display

官方提供信息:

  1. Linux内核版本 >= 5.8.x
  2. OpenCL >= 3.0 找不到源来安装


解决

要安装intel的专用内核,intel应该是在内核中基于OpenCL3.0支持了该GPU架构,但OpenCL3.0并未Release发布。

$ sudo apt install linux-image-intel

$ sudo reboot
$ clinfo
Number of platforms                               1                                                                                                      
  Platform Name                                   Intel(R) OpenCL HD Graphics                                                                            
  Platform Vendor                                 Intel(R) Corporation                                                                                   
  Platform Version                                OpenCL 3.0                                                                                             
  Platform Profile                                FULL_PROFILE                                                                                           
  Platform Extensions                             cl_khr_byte_addressable_store cl_khr_fp16 cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_icd cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_intel_command_queue_families cl_intel_subgroups cl_intel_required_subgroup_size cl_intel_subgroups_short cl_khr_spir cl_intel_accelerator cl_intel_driver_diagnostics cl_khr_priority_hints cl_khr_throttle_hints cl_khr_create_command_queue cl_intel_subgroups_char cl_intel_subgroups_long cl_khr_il_program cl_intel_mem_force_host_memory cl_khr_subgroup_extended_types cl_khr_subgroup_non_uniform_vote cl_khr_subgroup_ballot cl_khr_subgroup_non_uniform_arithmetic cl_khr_subgroup_shuffle cl_khr_subgroup_shuffle_relative cl_khr_subgroup_clustered_reduce cl_intel_device_attribute_query cl_khr_suggested_local_work_size cl_intel_planar_yuv cl_intel_packed_yuv cl_khr_image2d_from_buffer cl_khr_depth_images cl_khr_3d_image_writes cl_intel_media_block_io cl_intel_va_api_media_sharing cl_intel_sharing_format_query cl_khr_pci_bus_info cl_intel_subgroup_local_block_io                                                                                                                      
  Platform Host timer resolution                  1ns                                                                                                    
  Platform Extensions function suffix             INTEL                                                                                                  
                                                                                                                                                         
  Platform Name                                   Intel(R) OpenCL HD Graphics                                                                            
Number of devices                                 1                                                                                                      
  Device Name                                     Intel(R) UHD Graphics [0x4555]                                                                         
  Device Vendor                                   Intel(R) Corporation                                                                                   
  Device Vendor ID                                0x8086                                                                                                 
  Device Version                                  OpenCL 3.0 NEO                                                                                         
  Driver Version                                  22.15.22905                                                                                            
  Device OpenCL C Version                         OpenCL C 1.2                                                                                           
  Device Type                                     GPU                                                                                                    
  Device Profile                                  FULL_PROFILE                                                                                           
  Device Available                                Yes                                                                                                    
  Compiler Available                              Yes                                                                                                    
  Linker Available                                Yes                                                                                                    
  Max compute units                               16
  Max clock frequency                             800MHz
  Device Partition                                (core)
    Max number of sub-devices                     0
    Supported partition types                     None
    Supported affinity domains                    (n/a)
  Max work item dimensions                        3
  Max work item sizes                             256x256x256
  Max work group size                             256
  Preferred work group size multiple              32
  Max sub-groups per work group                   0
  Sub-group sizes (Intel)                         8, 16, 32
  Preferred / native vector sizes                 
    char                                                16 / 16      
    short                                                8 / 8       
    int                                                  4 / 4       
    long                                                 1 / 1       
    half                                                 8 / 8        (cl_khr_fp16)
    float                                                1 / 1       
    double                                               1 / 1        (n/a)
  Half-precision Floating-point support           (cl_khr_fp16)
    Denormals                                     Yes
    Infinity and NANs                             Yes
    Round to nearest                              Yes
    Round to zero                                 Yes
    Round to infinity                             Yes
    IEEE754-2008 fused multiply-add               Yes
    Support is emulated in software               No
  Single-precision Floating-point support         (core)
    Denormals                                     Yes
    Infinity and NANs                             Yes
    Round to nearest                              Yes
    Round to zero                                 Yes
    Round to infinity                             Yes
    IEEE754-2008 fused multiply-add               Yes
    Support is emulated in software               No
    Correctly-rounded divide and sqrt operations  No
  Double-precision Floating-point support         (n/a)
  Address bits                                    32, Little-Endian
  Global memory size                              3162546176 (2.945GiB)
  Error Correction support                        No
  Max memory allocation                           1581273088 (1.473GiB)
  Unified memory for Host and Device              Yes
  Shared Virtual Memory (SVM) capabilities        (core)
    Coarse-grained buffer sharing                 No
    Fine-grained buffer sharing                   No
    Fine-grained system sharing                   No
    Atomics                                       No
  Minimum alignment for any data type             128 bytes
  Alignment of base address                       1024 bits (128 bytes)
  Preferred alignment for atomics                 
    SVM                                           64 bytes
    Global                                        64 bytes
    Local                                         64 bytes
  Max size for global variable                    0
  Preferred total size of global vars             0
  Global Memory cache type                        Read/Write
  Global Memory cache size                        524288 (512KiB)
  Global Memory cache line size                   64 bytes
  Image support                                   Yes
    Max number of samplers per kernel             16
    Max size for 1D images from buffer            98829568 pixels
    Max 1D or 2D image array size                 2048 images
    Base address alignment for 2D image buffers   4 bytes
    Pitch alignment for 2D image buffers          4 pixels
    Max 2D image size                             16384x16384 pixels
    Max planar YUV image size                     16384x16352 pixels
    Max 3D image size                             16384x16384x2048 pixels
    Max number of read image args                 128
    Max number of write image args                128
    Max number of read/write image args           128
  Max number of pipe args                         0
  Max active pipe reservations                    0
  Max pipe packet size                            0
  Local memory type                               Local
  Local memory size                               65536 (64KiB)
  Max number of constant args                     8
  Max constant buffer size                        1581273088 (1.473GiB)
  Max size of kernel argument                     2048 (2KiB)
  Queue properties (on host)                      
    Out-of-order execution                        Yes
    Profiling                                     Yes
  Queue properties (on device)                    
    Out-of-order execution                        No
    Profiling                                     No
    Preferred size                                0
    Max size                                      0
  Max queues on device                            0
  Max events on device                            0
  Prefer user sync for interop                    Yes
  Profiling timer resolution                      52ns
  Execution capabilities                          
    Run OpenCL kernels                            Yes
    Run native kernels                            No
    Sub-group independent forward progress        No
    IL version                                    SPIR-V_1.2 
    SPIR versions                                 1.2 
  printf() buffer size                            4194304 (4MiB)
  Built-in kernels                                (n/a)
  Device Extensions                               cl_khr_byte_addressable_store cl_khr_fp16 cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_icd cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_intel_command_queue_families cl_intel_subgroups cl_intel_required_subgroup_size cl_intel_subgroups_short cl_khr_spir cl_intel_accelerator cl_intel_driver_diagnostics cl_khr_priority_hints cl_khr_throttle_hints cl_khr_create_command_queue cl_intel_subgroups_char cl_intel_subgroups_long cl_khr_il_program cl_intel_mem_force_host_memory cl_khr_subgroup_extended_types cl_khr_subgroup_non_uniform_vote cl_khr_subgroup_ballot cl_khr_subgroup_non_uniform_arithmetic cl_khr_subgroup_shuffle cl_khr_subgroup_shuffle_relative cl_khr_subgroup_clustered_reduce cl_intel_device_attribute_query cl_khr_suggested_local_work_size cl_intel_planar_yuv cl_intel_packed_yuv cl_khr_image2d_from_buffer cl_khr_depth_images cl_khr_3d_image_writes cl_intel_media_block_io cl_intel_va_api_media_sharing cl_intel_sharing_format_query cl_khr_pci_bus_info cl_intel_subgroup_local_block_io 

NULL platform behavior
  clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...)  Intel(R) OpenCL HD Graphics
  clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...)   Success [INTEL]
  clCreateContext(NULL, ...) [default]            Success [INTEL]
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_DEFAULT)  Success (1)
    Platform Name                                 Intel(R) OpenCL HD Graphics
    Device Name                                   Intel(R) UHD Graphics [0x4555]
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU)  Success (1)
    Platform Name                                 Intel(R) OpenCL HD Graphics
    Device Name                                   Intel(R) UHD Graphics [0x4555]
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL)  Success (1)
    Platform Name                                 Intel(R) OpenCL HD Graphics
    Device Name                                   Intel(R) UHD Graphics [0x4555]

ICD loader properties
  ICD loader Name                                 OpenCL ICD Loader
  ICD loader Vendor                               OCL Icd free software
  ICD loader Version                              2.2.11
  ICD loader Profile                              OpenCL 2.1
        NOTE:   your OpenCL library only supports OpenCL 2.1,
                but some installed platforms support OpenCL 3.0.
                Programs using 3.0 features may crash
                or behave unexpectedly

$ ./hello_query_device 
[ INFO ] OpenVINO Runtime version ......... 2022.1.0
[ INFO ] Build ........... 2022.1.0-7019-cdb9bec7210-releases/2022/1
[ INFO ] 
[ INFO ] Available devices: 
[ INFO ] CPU
[ INFO ]        SUPPORTED_PROPERTIES: 
[ INFO ]                Immutable: AVAILABLE_DEVICES : ""
[ INFO ]                Immutable: RANGE_FOR_ASYNC_INFER_REQUESTS : 1 1 1
[ INFO ]                Immutable: RANGE_FOR_STREAMS : 1 4
[ INFO ]                Immutable: FULL_DEVICE_NAME : Intel(R) Celeron(R) J6413 @ 1.80GHz
[ INFO ]                Immutable: OPTIMIZATION_CAPABILITIES : FP32 FP16 INT8 BIN EXPORT_IMPORT
[ INFO ]                Immutable: CACHE_DIR : ""
[ INFO ]                Mutable: NUM_STREAMS : 1
[ INFO ]                Mutable: AFFINITY : CORE
[ INFO ]                Mutable: INFERENCE_NUM_THREADS : 0
[ INFO ]                Mutable: PERF_COUNT : NO
[ INFO ]                Mutable: INFERENCE_PRECISION_HINT : f32
[ INFO ]                Mutable: PERFORMANCE_HINT : ""
[ INFO ]                Mutable: PERFORMANCE_HINT_NUM_REQUESTS : 0
[ INFO ] 
[ INFO ] GNA
[ INFO ]        SUPPORTED_PROPERTIES: 
[ INFO ]                Immutable: AVAILABLE_DEVICES : GNA_SW
[ INFO ]                Immutable: OPTIMAL_NUMBER_OF_INFER_REQUESTS : 1
[ INFO ]                Immutable: RANGE_FOR_ASYNC_INFER_REQUESTS : 1 1 1
[ INFO ]                Immutable: OPTIMIZATION_CAPABILITIES : INT16 INT8 EXPORT_IMPORT
[ INFO ]                Immutable: FULL_DEVICE_NAME : GNA_SW
[ INFO ]                Immutable: GNA_LIBRARY_FULL_VERSION : 3.0.0.1455
[ INFO ]                Mutable: GNA_SCALE_FACTOR_PER_INPUT : ""
[ INFO ]                Mutable: GNA_FIRMWARE_MODEL_IMAGE : ""
[ INFO ]                Mutable: GNA_DEVICE_MODE : GNA_SW_EXACT
[ INFO ]                Mutable: GNA_HW_EXECUTION_TARGET : UNDEFINED
[ INFO ]                Mutable: GNA_HW_COMPILE_TARGET : UNDEFINED
[ INFO ]                Mutable: GNA_PWL_DESIGN_ALGORITHM : UNDEFINED
[ INFO ]                Mutable: GNA_PWL_MAX_ERROR_PERCENT : 1.000000
[ INFO ]                Mutable: PERFORMANCE_HINT : ""
[ INFO ]                Mutable: INFERENCE_PRECISION_HINT : undefined
[ INFO ]                Mutable: PERFORMANCE_HINT_NUM_REQUESTS : 1
[ INFO ]                Mutable: LOG_LEVEL : LOG_NONE
[ INFO ] 
[ INFO ] GPU
[ INFO ]        SUPPORTED_PROPERTIES: 
[ INFO ]                Immutable: AVAILABLE_DEVICES : 0
[ INFO ]                Immutable: RANGE_FOR_ASYNC_INFER_REQUESTS : 1 2 1
[ INFO ]                Immutable: RANGE_FOR_STREAMS : 1 2
[ INFO ]                Immutable: OPTIMAL_BATCH_SIZE : 1
[ INFO ]                Immutable: MAX_BATCH_SIZE : 1
[ INFO ]                Immutable: FULL_DEVICE_NAME : Intel(R) UHD Graphics [0x4555] (iGPU)
[ INFO ]                Immutable: DEVICE_TYPE : integrated
[ INFO ]                Immutable: DEVICE_GOPS : f16 409.6 f32 204.8 i8 204.8 u8 204.8
[ INFO ]                Immutable: OPTIMIZATION_CAPABILITIES : FP32 BIN FP16
[ INFO ]                Immutable: GPU_DEVICE_TOTAL_MEM_SIZE : 3162546176
[ INFO ]                Immutable: GPU_UARCH_VERSION : 11.0.0
[ INFO ]                Immutable: GPU_EXECUTION_UNITS_COUNT : 16
[ INFO ]                Immutable: GPU_MEMORY_STATISTICS : ""
[ INFO ]                Mutable: PERF_COUNT : NO
[ INFO ]                Mutable: MODEL_PRIORITY : MEDIUM
[ INFO ]                Mutable: GPU_HOST_TASK_PRIORITY : MEDIUM
[ INFO ]                Mutable: GPU_QUEUE_PRIORITY : MEDIUM
[ INFO ]                Mutable: GPU_QUEUE_THROTTLE : MEDIUM
[ INFO ]                Mutable: GPU_ENABLE_LOOP_UNROLLING : YES
[ INFO ]                Mutable: CACHE_DIR : ""
[ INFO ]                Mutable: PERFORMANCE_HINT : ""
[ INFO ]                Mutable: COMPILATION_NUM_THREADS : 4
[ INFO ]                Mutable: NUM_STREAMS : 1
[ INFO ]                Mutable: PERFORMANCE_HINT_NUM_REQUESTS : 0
[ INFO ]                Mutable: DEVICE_ID : 0
[ INFO ]


用官方Docker镜像验证一下

$ sudo apt install docker.io

$ sudo docker pull openvino/ubuntu20_runtime
$ sudo docker run -itu root:root  --rm --device /dev/dri:/dev/dri openvino/ubuntu20_runtime /bin/bash

$ sudo docker pull openvino/ubuntu18_runtime
$ sudo docker run -itu root:root  --rm --device /dev/dri:/dev/dri openvino/ubuntu18_runtime /bin/bash