pycharm YOLOv5报错

NoneType"object has no attribute "_free_weak_ref"怎么解决啊

报错是在torch/modules/里的.py文件

应该是pytorch版本问题,1.11有问题,可以改到1.8.0 https://github.com/ultralytics/yolov5/issues/6962
pip install --upgrade --force-reinstall torch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0

"NoneType"object has no attribute "_free_weak_ref"是说你调用_free_weak_ref属性的对象的值是 None
应该是这个对象没有获取成功