這篇文章主要介紹“怎么解決TensorFlowGPU版出現(xiàn)OOM錯誤的問題”,在日常操作中,相信很多人在怎么解決TensorFlowGPU版出現(xiàn)OOM錯誤的問題問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”怎么解決TensorFlowGPU版出現(xiàn)OOM錯誤的問題”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!

問題:
在使用mask_rcnn預(yù)測自己的數(shù)據(jù)集時,會出現(xiàn)下面錯誤:
ResourceExhaustedError: OOM when allocating tensor with shape[1,512,1120,1120] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc [[{{node rpn_model/rpn_conv_shared/convolution}} = Conv2D[T=DT_FLOAT, data_format="NCHW", dilations=[1, 1, 1, 1], padding="SAME", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/device:GPU:0"](fpn_p2/BiasAdd, rpn_conv_shared/kernel/read)]]Hint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info. [[{{node roi_align_mask/strided_slice_17/_4277}} = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_3068_roi_align_mask/strided_slice_17", tensor_type=DT_INT32, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]Hint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.
原因:
一是、因為圖片尺寸為3200*4480,圖片的尺寸太大。
二是、我使用的是TensorFlow GPU版,而我GPU的顯存只有8G,導(dǎo)致顯存不夠。
解決:
一是、將圖片尺寸改小,小到占用的內(nèi)存比顯存。
二是、不使用GPU進行預(yù)測,只使用CPU預(yù)測,因為一般CPU內(nèi)存要大于顯存的。但裝的又是GPU版的TensorFlow,所以需要在預(yù)測程序進行更改。
程序在前兩行加入下面代碼:
import osos.environ["CUDA_VISIBLE_DEVICES"] = ""
引號里填的是GPU的序號,不填的時候代表不使用GPU。
到此,關(guān)于“怎么解決TensorFlowGPU版出現(xiàn)OOM錯誤的問題”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>
                網(wǎng)站欄目:怎么解決TensorFlowGPU版出現(xiàn)OOM錯誤的問題-創(chuàng)新互聯(lián)
                
                文章URL:http://www.chinadenli.net/article22/dcsojc.html
            
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供自適應(yīng)網(wǎng)站、靜態(tài)網(wǎng)站、網(wǎng)站制作、網(wǎng)站維護、品牌網(wǎng)站設(shè)計、定制開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)