今天安装在github上的InvoiceNet开源项目,准备对它进行测试,安装过程出现了一些问题,做个记录,给遇到兄弟爬坑。
第一个问题,conda的问题,
这是另外一个包管理器,不仅仅可以管理python的虚拟环境,还能管理很多其他语言的包或库,主要是科学计算、人工智能领域的开发者用的比较多,(感叹:这个时代的轮子太多了)
第二个问题,执行pip install .的命令时,提示:ERROR: No matching distribution found for tensorflow==2.13.1
在网上找了半天,大致是说在pypi上找不到对应版本的包,唉~~为啥这包就没有了呢?只放最新的吗?
后来想到别人应该也会遇到,于是到项目的问题列表中找了一下,果不其然,有人遇到https://github.com/naiveHobo/InvoiceNet/issues/117
解决的办法是在setup.py中,去掉指定的tensorflow的版本号,我这就有点奇怪了,既然这个问题早就有了,为啥在setup.py中不修改一下呢?还有那个numpy的版本,而且这两个的版本号在setup.py中还是单独指定的,真是有点不太理解。懂的兄弟可以给解惑一下,谢啦。
去掉了版本号,终于可以正常执行pip install .了
第三个问题:执行训练工具报错:
执行完成后,运行训练工具,但是报错:
shell
(invoicenet) D:\Projects\AI\InvoiceNet>python trainer.py
2024-07-22 21:33:31.035230: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2024-07-22 21:33:31.035436: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Traceback (most recent call last):
File "trainer.py", line 22, in <module>
from invoicenet.gui.trainer import Trainer
File "D:\Projects\AI\InvoiceNet\invoicenet\gui\trainer.py", line 36, in <module>
from ..acp.acp import AttendCopyParse
File "D:\Projects\AI\InvoiceNet\invoicenet\acp\acp.py", line 24, in <module>
import tensorflow as tf
File "C:\Users\Atom\.conda\envs\invoicenet\lib\site-packages\tensorflow\__init__.py", line 37, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\Users\Atom\.conda\envs\invoicenet\lib\site-packages\tensorflow\python\__init__.py", line 37, in <module>
from tensorflow.python.eager import context
File "C:\Users\Atom\.conda\envs\invoicenet\lib\site-packages\tensorflow\python\eager\context.py", line 29, in <module>
from tensorflow.core.framework import function_pb2
File "C:\Users\Atom\.conda\envs\invoicenet\lib\site-packages\tensorflow\core\framework\function_pb2.py", line 16, in <module>
from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
File "C:\Users\Atom\.conda\envs\invoicenet\lib\site-packages\tensorflow\core\framework\attr_value_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
File "C:\Users\Atom\.conda\envs\invoicenet\lib\site-packages\tensorflow\core\framework\tensor_pb2.py", line 16, in <module>
from tensorflow.core.framework import resource_handle_pb2 as tensorflow_dot_core_dot_framework_dot_resource__handle__pb2
File "C:\Users\Atom\.conda\envs\invoicenet\lib\site-packages\tensorflow\core\framework\resource_handle_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_shape_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__shape__pb2
File "C:\Users\Atom\.conda\envs\invoicenet\lib\site-packages\tensorflow\core\framework\tensor_shape_pb2.py", line 42, in <module>
serialized_options=None, file=DESCRIPTOR),
File "C:\Users\Atom\.conda\envs\invoicenet\lib\site-packages\google\protobuf\descriptor.py", line 561, in __new__
_message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not 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
报错"cudart64_110.dll not found",dll不存在,搜索资料后发现是nvida的cuda开发工具
shell
2024-07-22 22:41:34.544495: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2024-07-22 22:41:34.544737: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
没看仔细这个只是个警告信息,不影响,下面的部分才是异常,白搞了半天
根据异常信息搜索,在statckoverflow找到了答案:
https://stackoverflow.com/questions/72441758/typeerror-descriptors-cannot-not-be-created-directly
这个是原文截图
shell
(invoicenet) D:\Projects\AI\InvoiceNet>pip install protobuf==3.20.*
Collecting protobuf==3.20.*
Downloading protobuf-3.20.3-cp37-cp37m-win_amd64.whl.metadata (699 bytes)
Downloading protobuf-3.20.3-cp37-cp37m-win_amd64.whl (905 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 905.1/905.1 kB 1.8 MB/s eta 0:00:00
Installing collected packages: protobuf
Attempting uninstall: protobuf
Found existing installation: protobuf 4.24.4
Uninstalling protobuf-4.24.4:
Successfully uninstalled protobuf-4.24.4
终于成功了
安装完成后重新运行:python trainer.py,启动成功
终于启动成功了!