zoukankan      html  css  js  c++  java
  • Hadoop 3.1.1

    在 Yarn 上使用 FPGA

    前提

    • YARN 目前只支持通过 IntelFpgaOpenclPlugin 发布的 FPGA 资源
    • YARN NodeManager 所在的机器上必须预先安装供应商的驱动程序并配置好必需的环境变量。
    • Docker 容器尚不支持。

    配置

    FPGA 调度

    在 resource-types.xml添加如下配置

    <configuration>
      <property>
         <name>yarn.resource-types</name>
         <value>yarn.io/fpga</value>
      </property>
    </configuration>

    在 yarn-site.xml 中DominantResourceCalculator 必须被配置以启用 FPGA 调度和隔离。 在 capacity-scheduler.xml 中使用如下参数以配置 DominantResourceCalculator

    参数默认值
    yarn.scheduler.capacity.resource-calculator org.apache.hadoop.yarn.util.resource.DominantResourceCalculator

    FPGA 隔离

    yarn-site.xml

    <property>
      <name>yarn.nodemanager.resource-plugins</name>
      <value>yarn-io/fpga</value>
    </property>

    这将在 NodeManager 上启用 FPGA 隔离模块。

    如果配置了上述参数,YARN 会自动检测和配置 FPGA。如果管理员由特殊的需求,以下参数需要在 yarn-site.xml 中配置。

    1) 运行的 FPGA 设备

    参数默认值
    yarn.nodemanager.resource-plugins.fpga.allowed-fpga-devices auto

    指明由 Yarn NodeManager 管理的 FPGA 设备,用逗号分隔。GPU 卡的数量将被汇报给 ResourceManager用于调度。默认值 auto 代表让 YARN 从系统中自动发现 GPU 卡。

    如果管理员只希望一部分的 FPGA 设备被 Yarn 管理,请人为地指明可用的 FPGA 设备。因为当前只能配置为 c-e.cfg 中的一个主设备号,FPGA 设备由其次设备号标识。对于 Intel 设备,可以通过执行命令 aocl diagnose 并用解析设备名称对应的 uevent 来获取次设备号。

    2) 发现 FPGA 设备的可执行程序

    参数默认值
    yarn.nodemanager.resource-plugins.fpga.path-to-discovery-executables  

    当给定了 yarn.nodemanager.resource.fpga.allowed-fpga-devices=auto,YARN NodeManager 将执行 FPGA 发现的可执行程序(目前只支持 IntelFpgaOpenclPlugin)来收集 FPGA 信息。如果值为空(默认值),YARN NodeManager 将根据供应商的插件选项自行寻找。举例来说,IntelFpgaOpenclPlugin 会从环境 ALTERAOCLSDKROOT 的目录中查找 aocl 信息。

    3) 使用的 FPGA 插件

    参数默认值
    yarn.nodemanager.resource-plugins.fpga.vendor-plugin.class org.apache.hadoop.yarn.server.nodemanager.containermanager.resourceplugin.fpga.IntelFpgaOpenclPlugin

    当前,只支持 Intel OpenCL SDK for FPGA。FPGA 上运行的 IP 程序(.aocx 文件)必须基于 Intel 平台的 OpenCL 提供。

    4) CGroups 挂载

    FPGA 隔离使用 CGroup 设备控制器 来实现 FPGA 设备之间的隔离。为了自动挂载次设备到 CGroups,以下配置要添加到 yarn-site.xml 文件中。否则,管理员必须人为地创建设备子目录以使用该功能。

    参数默认值
    yarn.nodemanager.linux-container-executor.cgroups.mount true

    想知道 Yarn 使用 CGroup 的更多信息,请参阅使用 CGroups

    container-executor.cfg

    通常需要添加如下配置到 container-executor.cfg 中。fpag.major-device-number 和 allowed-device-minor-numbers 是可选参数,指明允许的 FPGA 设备。

    [fpga]
    module.enabled=true
    fpga.major-device-number=## FPGA 的主设备号,默认是 246。强烈建议设置该参数。
    fpga.allowed-device-minor-numbers=## 逗号分隔的次设备号,空值代表由 Yarn 管理所有的 FPGA 设备。

    如果用户要在非 Docker 环境下运行 FPGA 程序:

    [cgroups]
    # 系统 Cgroup 的根目录(不能为空或“/”)
    root=/cgroup
    # YARN CGroup 的父目录
    yarn-hierarchy=yarn

    使用

    Distributed-shell + FPGA

    分布式 Shell 程序在内存和虚拟核之外,还支持申请更多的资源类型。

    不使用 Docker 运行分布式 Shell 程序(.bashrc 配置了 SDK 相关的环境变量):

    yarn jar <path/to/hadoop-yarn-applications-distributedshell.jar> 
      -jar <path/to/hadoop-yarn-applications-distributedshell.jar> 
      -shell_command "source /home/yarn/.bashrc && aocl diagnose" 
      -container_resources memory-mb=2048,vcores=2,yarn.io/fpga=1 
      -num_containers 1

    对于已经启动的任务,你将从日志中看到如下的输出:

    aocl diagnose: Running diagnose from /home/fpga/intelFPGA_pro/17.0/hld/board/nalla_pcie/linux64/libexec
    
    ------------------------- acl0 -------------------------
    Vendor: Nallatech ltd
    
    Phys Dev Name  Status   Information
    
    aclnalla_pcie0Passed   nalla_pcie (aclnalla_pcie0)
                           PCIe dev_id = 2494, bus:slot.func = 02:00.00, Gen3 x8
                           FPGA temperature = 54.4 degrees C.
                           Total Card Power Usage = 32.4 Watts.
                           Device Power Usage = 0.0 Watts.
    
    DIAGNOSTIC_PASSED
    ---------------------------------------------------------

    在启动容器前指定 Yarn 需要配置的 IP

    对于 FPGA 资源,容器可以通过环境变量 REQUESTED_FPGA_IP_ID 来让 YARN 下载并分配一个 IP 给它。举例来说,REQUESTED_FPGA_IP_ID=“matrix_mul” 会触发在容器本地目录中查找名称包含 matirx_mul 字样的 IP 文件(.aocx 文件),程序必须首先将该文件分发到各个容器。当前只支持为所有设备分配一个 IP。如果用户不设置该环境变量,则表示用户程序将自行查找 IP 文件。需要注意的是,提前 下载 IP 并重新编程在 Yarn 中并不是必需的,因为 OpenCL 程序可以在运行时查找 IP 文件并重新编程设备。但 Yarn 为容器完成这一步骤,以实现最快的重新编程。

  • 相关阅读:
    uva 10369 Arctic Network
    uvalive 5834 Genghis Khan The Conqueror
    uvalive 4848 Tour Belt
    uvalive 4960 Sensor Network
    codeforces 798c Mike And Gcd Problem
    codeforces 796c Bank Hacking
    codeforces 768c Jon Snow And His Favourite Number
    hdu 1114 Piggy-Bank
    poj 1276 Cash Machine
    bzoj 2423 最长公共子序列
  • 原文地址:https://www.cnblogs.com/shishaochen/p/9655162.html
Copyright © 2011-2022 走看看