代碼鏈接:https://github.com/amdegroot/ssd.pytorch
1.執行demo-ssd.py,改動detection.py中49行:
if scores.numel() == 0:#scores.dim()
2. multibox_loss.py 中,97行
“loss_c[pos] = 0” 調試過程中發現 loss_c的shape與pos的shape 不同,會出現不匹配錯誤,因此將此句改爲以下:
loss_c[pos.view(-1,1)] = 0
將pos通過view(-1,1) 改爲與loss_c相匹配的shape。
3.multibox_loss.py中 N=num_pos.data.sum()的dtype爲torch.int64,而進行除法操作的 loss_l 與loss_c的dtype爲torch.float32,執行時會出現 ‘torch.cuda.LongTensor but found type torch.cuda.FloatTensor for argument’類似錯誤,此時需要查看參數類型,將N的類型改爲torch.float32即可。
N = num_pos.data.sum() N=N.float()
4.train.py代碼中,在迭代過程中,每次執行batch張圖片,通過images, targets = next(batch_iterator)讀取圖片時,如果next()中沒有數據後會觸發Stoplteration異常,使用下面語句替換 images, targets = next(batch_iterator)將解決這種異常問題。
while True: try: # 獲得下一個值: images, targets = next(batch_iterator) except StopIteration: # 遇到StopIteration就退出循環 break
5.RuntimeError: CUDNN_STATUS_INTERNAL_ERROR的解決辦法:
需要清除CUDA緩存,使用sudo進行,但它屬於Linux命令,windows中需要進行以下操作:
(1).在任意目錄中新建文本文件,命名爲sudo.js
(2).用記事本打開剛纔新建的文件,粘貼下面代碼
var command = WScript.Arguments.Item(0); |
使用cmd打開sudo.js文件即可進行sudo操作。
(3).執行sudo rm -f ~/.nv/ (一定最後邊不要漏掉“/”,否則會提示“.nv”是目錄)