mxnet生成模型,load警告
src/nnvm/legacy_json_util.cc:204: Warning: loading symbol saved by MXNet version 10600 with lower version of MXNet
模型生成代码:
save_model_json.py
import sys
sys.path.append(r'/home/user1/recognition')
from config import config
import os
import mxnet as mx
from parall_module_local_v1_gluon_group import ParallModule
from train_0723 import get_symbol_embedding, get_symbol_arcface, parse_args
args = parse_args()
args.ctx_num = 4
args.batch_size = args.per_batch_size * args.ctx_num
num_workers = config.num_workers
global_num_ctx = num_workers * args.ctx_num
if config.num_classes % global_num_ctx == 0:
args.ctx_num_classes = config.num_classes // global_num_ctx
else:
args.ctx_num_classes = config.num_classes // global_num_ctx + 1
args.local_num_classes = args.ctx_num_classes * args.ctx_num
args.local_class_start = args.local_num_classes * args.worker_id
ctx = []
os.environ['CUDA_VISIBLE_DEVICES'] = '0,1,2,3'
cvd = os.environ['CUDA_VISIBLE_DEVICES'].strip()
if len(cvd) > 0:
for i in range(len(cvd.split(','))):
ctx.append(mx.gpu(i))
esym = get_symbol_embedding()
asym = get_symbol_arcface
model = ParallModule(
context=ctx,
symbol=esym,
data_names=['data'],
label_names=['softmax_label'],
asymbol=asym,
args=args,
)
all_layers = model.symbol.get_internals()
print(all_layers)
print(all_layers[len(all_layers) - 1])
_sym = all_layers['add_fc5_output'] # save all the layers, not need to specify the last fc1 layer
_sym.save('model-nogdn-symbol.json', remove_amp_cast=True)
原因:使用$ sudo python save_model_json.py
可能调用的python是2.7版本的或者其他版本,导致了对用的mxnet是cpu版或更低版本。最后load生成的模型会告警。需要检查 $ sudo python
是哪个版本。