2.3K Star 8.1K Fork 4.3K

GVPMindSpore / mindspore

 / 详情

[CI][MS][兼容性]联合CI-910A mindspore.load_mindir后配置usr_info字段,在ci39的conda环境中报错RepeatedCompositeFieldContainer object does not support item assignment

TODO
RFC 成员
创建于  
2024-03-15 16:16
name about labels
Bug Report Use this template for reporting a bug kind/bug

Describe the current behavior / 问题描述 (Mandatory / 必填)

[CI][MS]联合CI-910A mindspore.load_mindir后配置usr_info字段,在ci39的conda环境中报错

Environment / 环境信息 (Mandatory / 必填)

  • Hardware Environment(Ascend/GPU/CPU) / 硬件环境:

Please delete the backend not involved / 请删除不涉及的后端:
/device ascend/GPU/CPU/kirin/等其他芯片

  • Software Environment / 软件环境 (Mandatory / 必填):
    -- MindSpore version (e.g., 1.7.0.Bxxx) :
    -- Python version (e.g., Python 3.7.5) :
    -- OS platform and distribution (e.g., Linux Ubuntu 16.04):
    -- GCC/Compiler version (if compiled from source):

  • Excute Mode / 执行模式 (Mandatory / 必填)(PyNative/Graph):

Please delete the mode not involved / 请删除不涉及的模式:
/mode pynative
/mode graph

Related testcase / 关联用例 (Mandatory / 必填)

Steps to reproduce the issue / 重现步骤 (Mandatory / 必填)

  1. python3.9报错,运行如下用例
    Python 3.9.18 (main, Sep 11 2023, 13:51:18)
    [GCC 11.2.0] :: Anaconda, Inc. on linux
    Type "help", "copyright", "credits" or "license" for more information.

import mindspore
md = mindspore.load_mindir("/nvme1/workspace/pangu_sigma_output_wxr/model/mindir/pangu_sigma_4096_rank_0_graph.mindir")
md.user_info
[]
md.user_info["batch_size"]="1"
Traceback (most recent call last):
File "", line 1, in
File "/home/miniconda3/envs/ci39/lib/python3.9/site-packages/google/protobuf/internal/containers.py", line 325, in setitem
raise TypeError(
TypeError: RepeatedCompositeFieldContainer object does not support item assignment

  1. python3.7正常
    Python 3.7.6 | packaged by conda-forge | (default, Jun 1 2020, 18:15:32)
    [GCC 7.5.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.

import mindspore
md = mindspore.load_mindir("/nvme1/workspace/pangu_sigma_output_wxr/model/mindir/pangu_sigma_4096_rank_0_graph.mindir")
md.user_info
{}
md.user_info["batch_size"]="1"

Describe the expected behavior / 预期结果 (Mandatory / 必填)

Related log / screenshot / 日志 / 截图 (Mandatory / 必填)

Special notes for this issue/备注 (Optional / 选填)

ci3.9的conda list
packages in environment at /home/miniconda3/envs/ci39:
Name Version Build Channel
ascendctools 0.1.0
asttokens 2.4.1
astunparse 1.6.3
attrs 23.2.0
beautifulsoup4 4.12.3
biprof-tool 0.1.0
blinker 1.7.0
bs4 0.0.2
ca-certificates 2023.12.12 hd43f75c_0
certifi 2024.2.2
charset-normalizer 3.3.2
click 8.1.7
cloudpickle 3.0.0
decorator 5.1.1
filelock 3.13.1
Flask 3.0.2
fsspec 2024.2.0
ftfy 6.1.3
hccl 0.1.0
hccl-parser 0.1
huggingface-hub 0.20.3
idna 3.6
importlib-metadata 7.0.1
itsdangerous 2.1.2
jieba 0.42.1
Jinja2 3.1.3
joblib 1.3.2
latex2mathml 3.77.0
ld_impl_linux-aarch64 2.38 h8131f2d_1
libffi 3.4.4 h419075a_0
libgcc-ng 11.2.0 h1234567_1
libgfortran-ng 11.2.0 h6e398d7_1
libgfortran5 11.2.0 h1234567_1
libstdcxx-ng 11.2.0 h1234567_1
Markdown 3.5.2
MarkupSafe 2.1.5
mdtex2html 1.3.0
mindformers 1.1.0
mindpet 1.0.3
mindspore 2.3.0
mindspore-lite 2.3.0
mpi 1.0 mpich
mpi4py 3.1.4 py39hf17f674_0
mpich 3.3.2 hffc2117_0
mpmath 1.3.0
ncurses 6.4 h419075a_0
nltk 3.8.1
numpy 1.21.6
op-gen 0.1
op-test-frame 0.1
opencv-python-headless 4.9.0.80
openssl 3.0.13 h2f4d8fa_0
packaging 23.2
pillow 10.2.0
pip 23.3.1 py39hd43f75c_0
protobuf 4.25.3
psutil 5.9.8
pyarrow 12.0.1
python 3.9.18 h4bb2201_0
PyYAML 6.0.1
readline 8.2 h998d150_0
regex 2023.12.25
requests 2.31.0
rouge-chinese 1.0.3
scikit-learn 1.0.2
scipy 1.11.1
sentencepiece 0.2.0
setuptools 68.2.2 py39hd43f75c_0
six 1.16.0
soupsieve 2.5
sqlite 3.41.2 h998d150_0
sympy 1.12
synr 0.5.0
te 0.4.0
threadpoolctl 3.3.0
tk 8.6.12 h241ca14_0
tokenizers 0.15.0
tornado 6.4
tqdm 4.66.2
typing_extensions 4.9.0
tzdata 2023d h04d1e81_0
urllib3 2.2.1
wcwidth 0.2.13
Werkzeug 3.0.1
wheel 0.41.2 py39hd43f75c_0
xz 5.4.5 h998d150_0
zipp 3.17.0
zlib 1.2.13 h998d150_0

评论 (18)

188******92 创建了Bug-Report
188******92 添加了
 
kind/bug
标签
188******92 添加了
 
v2.3.0
标签
188******92 添加了
 
mindspore
标签
展开全部操作日志

Please assign maintainer to check this issue.
请为此issue分配处理人。
@188******92

感谢您的提问,您可以评论//mindspore-assistant更快获取帮助:

  1. 如果您刚刚接触MindSpore,或许您可以在教程找到答案
  2. 如果您是资深Pytorch用户,您或许需要:
  1. 如果您遇到动态图问题,可以设置set_context(pynative_synchronize=True)查看报错栈协助定位
  2. 模型精度调优问题可参考官网调优指南
  3. 如果您反馈的是框架BUG,请确认您在ISSUE中提供了MindSpore版本、使用的后端类型(CPU、GPU、Ascend)、环境、训练的代码官方链接以及可以复现报错的代码的启动方式等必要的定位信息
  4. 如果您已经定位出问题根因,欢迎提交PR参与MindSpore开源社区,我们会尽快review
188******92 修改了描述
188******92 修改了描述

先实例化,然后单独给字段赋值,只适用于基础类型

因此我们需要这么做

user_info.hobby.extend(["唱", "跳", "rap", "🏀"])
user_info.info.update({"name": "古明地觉", "age": "17"})
print(user_info.hobby)
print(user_info.info)
"""
['唱', '跳', 'rap', '🏀']
{'name': '古明地觉', 'age': '17'}
"""

先实例化,然后单独给字段赋值,只适用于基础类型

因此我们需要这么做

user_info.hobby.extend(["唱", "跳", "rap", "🏀"])
user_info.info.update({"name": "古明地觉", "age": "17"})
print(user_info.hobby)
print(user_info.info)
"""
['唱', '跳', 'rap', '🏀']
{'name': '古明地觉', 'age': '17'}
"""

@lanzhineng 该写法还是报错

188******92 添加了
 
sig/ascend
标签
188******92 添加了
 
sig/ascend
标签
188******92 移除了
 
sig/ascend
标签
188******92 移除了
 
sig/ascend
标签
188******92 移除了
 
sig/ascend
标签
188******92 移除了
 
sig/ascend
标签
188******92 添加了
 
device/ascend
标签

https://protobuf.dev/overview/ 这是第三软件的功能。protobuf 的map 在pyhton 不同版本用法不同,还是版本编译问题?

i-robot 添加了
 
protobuf
标签
这是第三方软件protobuf 的map 功能 和使用方法,按照三方库维护责任人列表 https://gitee.com/mindspore/community/blob/master/security/config/Third_Party_Open_Source_Software_List.yaml 
 url: https://github.com/protocolbuffers/protobuf
    handler: henryshi1
    milestone: B-SIG-FrontEnd
    schName: protobuf

转B-SIG-FrontEnd 继续定位。

i-robot 添加了
 
gitee
标签
i-robot 添加了
 
github
标签
lanzhineng 里程碑B-SIG-Compiler 修改为B-SIG-FrontEnd
lanzhineng 添加协作者lanzhineng
lanzhineng 负责人lanzhineng 修改为changzherui

issue中没有明确结论及处理办法

changzherui 添加协作者changzherui
changzherui 负责人changzherui 修改为huangbingjian

lanzhineng定位到是protobuf三方库问题,protobuf在Python 3.9和Python 3.7版本上行为不一致。map使用的是proto功能,在python 3.9按照python 3.7的写法不能使用。
根据三方库维护责任列表:https://gitee.com/mindspore/community/blob/master/security/config/Third_Party_Open_Source_Software_List.yaml ,protobuf由FrontEnd维护,建议按三方库责任分工去CCB。

如果功能不能使用,需在设计时明确交付范围。
该问题是:2.3mindir添加自定义信息特性bug,属于设计问题,

changzherui 添加协作者changzherui
changzherui 负责人changzherui 修改为fangwenyi
changzherui 里程碑B-SIG-FrontEnd 修改为B-SIG-TBD
huangbingjian 负责人fangwenyi 修改为lanzhineng
huangbingjian 添加协作者fangwenyi
huangbingjian 里程碑B-SIG-TBD 修改为B-SIG-Compiler

可以用两个proto string类型保存python的dict对象,不一定非要用map。
需重新考虑内部实现方案

(ci39) ubuntu:/test$ python --version
Python 3.9.12
(ci39) ubuntu:
/test$ protoc --version
libprotoc 26.1
(ci39) ubuntu:/test$ conda list|grep protoc
(ci39) ubuntu:
/test$ conda list|grep proto
protobuf 5.26.1 pypi_0 pypi
(ci39) ubuntu:~/test$ python
Python 3.9.12 (main, Jun 1 2022, 11:38:51)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.

from mindir import load_mindir
md = load_mindir("./test1.mindir")
md.user_info
{}
md.user_info["dd"] ="lan"
md.user_info
{'dd': 'lan'}

protobuf 和protoc 更新到最新版本 功能是正常的。 需要 mindspore 运行 环境python protobuf . 编译环境 protoc 正确的版本号。

升级第三方软件libprotoc protobuf_3.13.0_ 升级到最新稳定版本 libprotoc 26.1 。python protobuf 使用默认就可以。
编译环境python3.9 protobuf 版本配套问题

转pb版本升级需求

huangbingjian 添加了
 
ccb/rfc
标签
huangbingjian 任务类型Bug-Report 修改为RFC

20240328 CCB评审结论,该问题同意转需求。
与测试沟通同意后,该issue挂ccb/rfc标签,按照需求单进行跟踪。

问题:[CI][MS][兼容性]联合CI-910A mindspore.load_mindir后配置usr_info字段,在ci39的conda环境中报错RepeatedCompositeFieldContainer object does not support item assignment
https://e.gitee.com/mind_spore/dashboard?issue=I98W87

影响接口:mindspore.load_mindir( file_name)
调用该接口获得 protobuf 对象后,不能对该的用户自定义信息进行写操作。具体如下
import mindspore
md = mindspore.load_mindir("/nvme1/workspace/pangu_sigma_output_wxr/model/mindir/pangu_sigma_4096_rank_0_graph.mindir")
md.user_info
[]
md.user_info["batch_size"]="1"
Traceback (most recent call last):
File "", line 1, in
File "/home/miniconda3/envs/ci39/lib/python3.9/site-packages/google/protobuf/internal/containers.py", line 325, in setitem
raise TypeError(
TypeError: RepeatedCompositeFieldContainer object does not support item assignment

影响范围:phython 3.7.5 环境功能正常,python 3.9 默认存protobuf版本,在mindir中不能对的用户自定义信息进行写操作,需要protobuf 版本降级到3.19.6~3.17.3

问题根因:mindspore 的mindir 使用了第三方软件protobuf,在python 3.9 中protobuf 版本是protobuf 4.25.3,需要libprotoc 的版本protoc >= 3.19.0
但 mindspore python 3.9 使用libprotobuf 为 3.13.0.1。

为什么python3.7.5 是正常的呢?在python 3.7 中protobuf 版本是protobuf 3.17.3,可以匹配libprotobuf 3.13.0.1。

因此把python 3.9 中protobuf 版本降级到 protobuf 3.17.3 功能应该正常。测试验证 python 3.9 中protobuf 版本降级到3.19.6功能正常,4.25.3不行。

以下是 protobuf 官方 报错提示:并告知我们 他们的匹配关系。>>> from mindir import load_mindir
Traceback (most recent call last):
File "", line 1, in
File "/home/lanzhineng/test/mindir.py", line 3, in
from mindir39_pb2 import ModelProto as mindir_model
File "/home/lanzhineng/test/mindir39_pb2.py", line 33, in
_descriptor.EnumValueDescriptor(
File "/home/lanzhineng/.conda/envs/ci39/lib/python3.9/site-packages/google/protobuf/descriptor.py", line 789, in new
_message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:

  1. Downgrade the protobuf package to 3.20.x or lower.
  2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:

  1. Downgrade the protobuf package to 3.20.x or lower.
  2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#py

i-robot 添加了
 
developers
标签
i-robot 添加了
 
developers
标签
lanzhineng 里程碑B-SIG-Compiler 修改为B-SIG-FrontEnd
lanzhineng 添加协作者lanzhineng
lanzhineng 负责人lanzhineng 修改为changzherui
lanzhineng 取消协作者changzherui

常哲睿 2024-04-10 18:37
不升级也能改,issue转给我吧

wenli 添加了
 
v2.3.0.rc2
标签

commit_id = '[sha1]:eb182b96,[branch]:(HEAD,origin/master,origin/HEAD,master)'
windows也存在该问题

登录 后才可以发表评论

状态
负责人
项目
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
预计工期 (小时)
参与者(7)
7347217 changzherui 1584948547
Python
1
https://gitee.com/mindspore/mindspore.git
git@gitee.com:mindspore/mindspore.git
mindspore
mindspore
mindspore

搜索帮助