mxnet.base.MXNetError: src/imperative/./imperative_utils.h:70: Check failed: inputs[i]->ctx().dev_mask() == ctx.dev_mask() (1 vs. 2)

mxnet 训练错误:

mxnet.base.MXNetError: [14:42:22] src/imperative/./imperative_utils.h:70: Check failed: inputs[i]->ctx().dev_mask() == ctx.dev_mask() (1 vs. 2) Operator stack require all inputs live on the same context. But the first argument is on gpu(0) while the 2-th argument is on cpu(0)
 
这种错误就是数据存储不同导致的,前一个数据在gpu上面,后一个数据在cpu上面,导致错误异常。
 
修改方法:在某一个数据加上context限制,使用ctx=mx.gpu()或者ctx=mx.cpu()
 
原文地址:https://www.cnblogs.com/code-wangjun/p/10571752.html