Creating vNPUs

  • The commands for creating vNPUs using the npu-smi tool are basically the same for physical machines and virtual machines, so the commands listed in this section can be applied to both. However, vNPU creation on virtual machines is supported only by Atlas inference product.
  • To use static virtualization, run the npu-smi command in this section to create vNPUs and mount them to containers and then refer to Mounting a vNPU.
  • To use dynamic virtualization, skip this section without the need to create vNPUs in advance. Set parameters as follows during container startup.
    • Ascend Docker Runtime: For details, see Method 1: Mounting vNPUs Using Ascend Docker Runtime. Use the ASCEND_VISIBLE_DEVICES and ASCEND_VNPU_SPECS parameters to virtualize a physical processor into multiple vNPUs and mount them to the container.
    • Ascend Device Plugin and Volcano: For details, see Dynamic Virtualization. vNPUs are automatically created by APIs based on configuration requirements during job running.

Methods

  • Run the following command on a PM to set the virtualization mode (skip this command if vNPUs are created on a VM):

    npu-smi set -t vnpu-mode -d mode

    Table 1 Parameter description

    Type

    Description

    mode

    Virtual instance mode. The value is 0 or 1.

    • 0: container mode
    • 1: VM mode
  • Create a vNPU. Command:

    npu-smi set -t create-vnpu -i id -c chip_id -f vnpu_config [-v vnpu_id] [-g vgroup_id]

    Type

    Description

    id

    Device ID. The NPU ID obtained by running the npu-smi info -l command is the device ID.

    chip_id

    Chip ID. The chip ID is obtained by running the npu-smi info -m command.

    vnpu_config

    Name of the virtual instance template. For details, see "Virtualization Templates" in Virtualization Rules.

    vnpu_id

    ID of the vNPU to be created.

    • By default, the system allocates an ID to the vNPU upon the first creation. If you need to use the vnpu_id created before a restart, you can use the -v parameter to specify the vnpu_id that you want to use after the restart.
    • Value Range
      • Atlas inference product

        The value range of vnpu_id is [phy_id*16 + 100, phy_id * 16+107].

      • Atlas training product

        The value range of vnpu_id is [phy_id x 16 + 100, phy_id x 16 + 115].

      NOTE:

      phy_id indicates the physical ID of the processor. You can run the ls /dev/davinci* command to obtain it. For example, /dev/davinci0 indicates that the physical ID of the processor is 0.

    • If vnpu_id is set to 4294967295, the virtual device ID is not specified.
    • vNPUs with the same vnpu_id cannot be created on the same server.

    vgroup_id

    ID of the vGroup. The value ranges from 0 to 3. For details about vGroup, see "Virtualization Modes" in Virtualization Rules. This parameter is supported only by Atlas inference product.

    Sample usage:
    • Create a vNPU on processor 0 of device 0 based on the template vir02.
      npu-smi set -t create-vnpu -i 0 -c 0 -f vir02
              Status : OK         Message : Create vnpu success
    • Create a vNPU for processor 0 on device 0 and set vnpu_id to 103. The vNPU template is vir02.
      npu-smi set -t create-vnpu -i 0 -c 0 -f vir02 -v 103
              Status : OK         Message : Create vnpu success
    • Create a vNPU for processor 0 on device 0, and set vnpu_id to 100 and the vgroup_id to 1. The vNPU template is vir02.
      npu-smi set -t create-vnpu -i 0 -c 0 -f vir02 -v 100 -g 1
              Status : OK         Message : Create vnpu success
  • Configure the vNPU recovery status. This parameter is used to maintain the vNPU configuration upon device restart, so that the vNPU configuration is still valid after the device is restarted.

    npu-smi set -t vnpu-cfg-recover -d mode

    mode indicates whether vNPU configuration recovery is enabled. 1: enabled; 0: disabled. By default, vNPU configuration recovery is enabled.

    Run the following command to enable the vNPU configuration recovery.

    npu-smi set -t vnpu-cfg-recover -d 1

           Status : OK
           Message : The VNPU config recover mode Enable is set successfully.
  • Query the configuration recovery status of the vNPU.

    You can use the following command to query the configuration recovery status of the vNPU in the current environment.

    npu-smi info -t vnpu-cfg-recover

    VNPU config recover mode : Enable
  • Query the vNPU information. Command:

    npu-smi info -t info-vnpu -i id -c chip_id

    Parameter

    Description

    id

    Device ID. The NPU ID obtained by running the npu-smi info -l command is the device ID.

    chip_id

    Chip ID. The chip ID is obtained by running the npu-smi info -m command.

    To query the vNPU information, you can run the following command, which means to query the vNPU information of processor 0 on device 0.

    npu-smi info -t info-vnpu -i 0 -c 0

    The AI CPU and vGroup ID information can be returned for Atlas inference product, while cannot be returned for Atlas training product.