Python代码调试过程中可能遇到的报错合集(将持续更新)

发布于:2024-04-30 ⋅ 阅读:(37) ⋅ 点赞:(0)

1. 三维重建MVSNet代码调试

可能遇到的报错1

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).

报错1解决方法

报错1解决办法:在虚拟环境“You_env”中重新安装protobuf

pip install protobuf==3.20.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

可能遇到的报错2

self.num_batches_tracked = self.num_batches_tracked + 1 # type: ignore[has-type]
RuntimeError: CUDA error: no kernel image is available for execution on the device
CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.

报错2解决方法

问题参考详细见:pytorch算力报错讨论

报错2解决办法:在虚拟环境“You_env”中重新安装与当前显卡算力相匹配的环境依赖库

pip3 install torch torchvision torchaudio --force-reinstall  --extra-index-url https://download.pytorch.org/whl/cu111

注意,cu111根据你的cuda版本来设置,使用nvcc -V查看,如果显示11.4则使用cu114


网站公告

今日签到

点亮在社区的每一天
去签到