下载
中文
注册

调用Device失败

现象描述

调用Device失败(容器内),日志中报以下类似信息:

日志信息(1):日志中有打印ERROR信息“drvDeviceOpen”失败字样,如下所示。

[ascend][ERROR][2021-06-26-17:53:15:689064][curpid: 32707, 32707][devdrv][drvDeviceOpen 79]get phys failed, devId(0), phy_devId(0)

日志信息(2):查看内核日志(dmesg)中有打印“device is in used”字样。如下所示。

[52783.010878] [ascend] [ERROR] [devdrv] [devdrv_manager_container_table_devlist_add_ns 832] <drv_hlt_dsmi_te:5615> device is in used
[52783.010881] [ascend] [ERROR] [tsdrv] [devdrv_open 194] <drv_hlt_dsmi_te:5615> add to list failed. dev_id(0)
[52783.013546] [ascend] [devdrv] [devdrv_manager_container_get_devnum 1306] <drv_hlt_dsmi_te:5615> weird device number, dev_num = 0
[52783.013547] [ascend] [ERROR] [devdrv] [devdrv_manager_container_get_devlist_ns 1210] <drv_hlt_dsmi_te:5615> some devices are used by other docker, mnt_ns = 0xffff8d33a5963720
[52783.013548] [ascend] [ERROR] [devdrv] [devdrv_manager_container_get_davinci_devlist 1248] <drv_hlt_dsmi_te:5615> get davinci devlist failed, ret(-22).

可能原因

针对调用Device失败,可能原因如下:

  • 日志信息(1):Docker容器启动时未映射设备。
  • 日志信息(2):Device被其他容器占用。

处理步骤

  • 针对日志信息(1)可能原因,可以参考以下方法处理:

    在容器内使用 ls /dev 指令查看是否映射Device。

    如果查看到Docker容器内未映射设备,请参考CANN 软件安装指南资料启动容器,起Docker的命令中必须加挂载设备的参数,例如:

    --device=/dev/davinciX --device=/dev/davinci_manager --device=/dev/devmm_svm --device=/dev/hisi_hdc

  • 针对日志信息(2)可能原因,需要等使用该Device的容器被释放后再使用。

    可以在容器内执行ls /dev命令查看当前容器内分配到的DavinciX,使用同样的方法查看其他容器分配到的DavinciX,然后可以通过手工停止Docker容器(例如:docker stop 容器id)的方式提前释放Device。