CUDA out of memory. Tried to allocate 14763.13 GiB (GPU 3; 10.73 GiB total capacity; 165.28 MiB alre
生活随笔
收集整理的這篇文章主要介紹了
CUDA out of memory. Tried to allocate 14763.13 GiB (GPU 3; 10.73 GiB total capacity; 165.28 MiB alre
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
RuntimeError: CUDA out of memory. Tried to allocate 14763.13 GiB (GPU 3; 10.73 GiB total capacity; 165.28 MiB already allocated; 9.61 GiB free; 10.72 MiB cached)
原因:要將大量數(shù)據(jù)加載到GPU上時(shí)出現(xiàn)的錯(cuò)誤,數(shù)據(jù)量太大了
解決辦法:做數(shù)據(jù)的切分,一個(gè)batch一個(gè)batch的分批計(jì)算。在pytorch中有個(gè)Dataset類,可以自己定義一個(gè)加載數(shù)據(jù)的類,繼承Dataset,同時(shí)實(shí)現(xiàn)Dataset的兩個(gè)方法:getitem() 和 len() ,然后使用 Dataloader 對自定義的類進(jìn)行包裝后,在訓(xùn)練階段就可以讓pytorch自動為你批量加載數(shù)據(jù)了,具體的實(shí)現(xiàn)細(xì)節(jié)參考我的另一篇文章 Pytorch數(shù)據(jù)讀取(Dataset, DataLoader, DataLoaderIter)
總結(jié)
以上是生活随笔為你收集整理的CUDA out of memory. Tried to allocate 14763.13 GiB (GPU 3; 10.73 GiB total capacity; 165.28 MiB alre的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Hadoop 命令操作
- 下一篇: 集成学习(西瓜书学习)