【现象描述】
在Ascend环境安装MindSpore,运行网络脚本时,报如下错误
RuntimeError: mindspore/ccsrc/plugin/device/ascend/hal/device/ascend_memory_adapter.cc:47 Initialize] Malloc device memory failed, free memory size is less than half of total memory size.Device 0 Device HBM total size:34359738368 Device HBM free size:1929908224 may be other processes occupying this card, check as: ps -ef|grep python
复制
【原因分析】
出现此类错误是因为运行网络脚本的设备被占用,当前MindSpore框架在Ascend环境只支持每张卡运行一个网络脚本
【解决办法】
方法一:切换空闲设备
- 使用npu-smi info查询设备的使用情况,在当前问题场景主要查看HBM-Usage的使用情况,如下图2、3、6卡是空闲设备,npu-smi的详细使用方法
- 切换使用未被占用的device, export DEVICE_ID={device_id} //device_id取值0~7
- 重新执行训练脚本
方法二:杀死占用设备的网络脚本(不建议)
-
查询是否存在其他程序占用设备 ps -ef | grep python
-
若判断程序为无用进程可选择杀死进程 kill {pid}
-
重新执行网络脚本