name | about | labels |
---|---|---|
Bug Report | Use this template for reporting a bug | kind/bug |
[CI][MS]联合CI-910A mindspore.load_mindir后配置usr_info字段,在ci39的conda环境中报错
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
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
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"
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
Please assign maintainer to check this issue.
请为此issue分配处理人。
@188******92
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
感谢您的提问,您可以评论//mindspore-assistant更快获取帮助:
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 该写法还是报错
https://protobuf.dev/overview/ 这是第三软件的功能。protobuf 的map 在pyhton 不同版本用法不同,还是版本编译问题?
这是第三方软件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 继续定位。
issue中没有明确结论及处理办法
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,属于设计问题,
可以用两个proto string类型保存python的dict对象,不一定非要用map。
需重新考虑内部实现方案
(ci39) ubuntu:/test$ python --version/test$ protoc --version
Python 3.9.12
(ci39) ubuntu:
libprotoc 26.1
(ci39) ubuntu:/test$ conda list|grep protoc/test$ conda list|grep proto
(ci39) ubuntu:
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版本升级需求
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:
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:
More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#py
常哲睿 2024-04-10 18:37
不升级也能改,issue转给我吧
commit_id = '[sha1]:eb182b96,[branch]:(HEAD,origin/master,origin/HEAD,master)'
windows也存在该问题
登录 后才可以发表评论