nvidia xavier安裝完torch1.7後出現Hardswish‘ object has no attribute ‘inplace‘
阿新 • • 發佈:2021-01-28
技術標籤:深度學習yolov5pytorchyolov5python
cuda10.2的nvidia xavier安裝完torch1.7後,跑yolov5的detect檔案,出現如下錯誤:
torch.nn.modules.module.ModuleAttributeError: ‘Hardswish‘ object has no attribute ‘inplace‘
有的部落格提到了降低torch以及torchvision的版本,但是好不容易安裝好的torch,我不太想重來,所以就採用了另一種方法:
conda activate yolov5_env python import torch print(torch.__path__)
找到了torch的路徑後,編輯/torch/nn/modules/activation.py,在438把“,self.inplace”刪掉。
def forward(self, input: Tensor) -> Tensor:
#return F.hardswish(input, self.inplace)
return F.hardswish(input)
然後再次執行就不會報錯了。