国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

RuntimeError: DefaultCPUAllocator: not enough memory: you tried to allocate 1105920 bytes.

這篇具有很好參考價(jià)值的文章主要介紹了RuntimeError: DefaultCPUAllocator: not enough memory: you tried to allocate 1105920 bytes.。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

問題

RuntimeError: [enforce fail at ..\c10\core\CPUAllocator.cpp:76] data. DefaultCPUAllocator: not enough memory: you tried to allocate 1105920 bytes.

RuntimeError: DefaultCPUAllocator: not enough memory: you tried to allocate 1105920 bytes.

今天在使用自己電腦跑YOLOV7的時(shí)候,因?yàn)樽约簺]有GPU所以使用CPU來跑測(cè)試模型,使用CPU來進(jìn)行一張獨(dú)立的圖像進(jìn)行預(yù)測(cè),跑一張圖像完全沒有問題,非常的nice?。。〉?,但是我接下來進(jìn)行一段視頻(多張圖像)的預(yù)測(cè),他給我說內(nèi)存分配不足

DefaultCPUAllocator: not enough memory: you tried to allocate 1105920 bytes.,

而且它這個(gè)不是在跑第二張圖像的是后出現(xiàn)的,是在計(jì)算第17張圖像時(shí)出現(xiàn),后面多次內(nèi)存釋放都不行~~~~~~~~

分析

在pytorch中,tensor有一個(gè)requires_grad參數(shù),如果設(shè)置為True,則反向傳播時(shí),該tensor就會(huì)自動(dòng)求導(dǎo)。tensor的requires_grad的屬性默認(rèn)為False,若一個(gè)節(jié)點(diǎn)(葉子變量:自己創(chuàng)建的tensor)requires_grad被設(shè)置為True,那么所有依賴它的節(jié)點(diǎn)requires_grad都為True(即使其他相依賴的tensor的requires_grad = False)


requires_grad是Pytorch中通用數(shù)據(jù)結(jié)構(gòu)Tensor的一個(gè)屬性,用于說明當(dāng)前量是否需要在計(jì)算中保留對(duì)應(yīng)的梯度信息,以線性回歸為例,容易知道權(quán)重w和偏差b為需要訓(xùn)練的對(duì)象,為了得到最合適的參數(shù)值,我們需要設(shè)置一個(gè)相關(guān)的損失函數(shù),根據(jù)梯度回傳的思路進(jìn)行訓(xùn)練。


當(dāng)requires_grad設(shè)置為False時(shí),反向傳播時(shí)就不會(huì)自動(dòng)求導(dǎo)了,因此大大節(jié)約了顯存或者說內(nèi)存。

那么本問題的解決方法也就隨之而來, 在測(cè)試的時(shí)候讓模型不要記錄梯度就好, 因?yàn)槠鋵?shí)也用不到。

解決方法

使用 with torch.no_grad(),在測(cè)試的時(shí)候讓模型不要保存梯度:

with torch.no_grad():
    output, _ = model(image) # 在圖像計(jì)算前加入

RuntimeError: DefaultCPUAllocator: not enough memory: you tried to allocate 1105920 bytes.

這樣在模型對(duì)每張圖像進(jìn)行計(jì)算的時(shí)候,不會(huì)再去求導(dǎo),梯度不會(huì)保存!

完美解決!

希望這篇文章對(duì)你有用!
謝謝點(diǎn)贊評(píng)論!文章來源地址http://www.zghlxwxcb.cn/news/detail-412293.html

到了這里,關(guān)于RuntimeError: DefaultCPUAllocator: not enough memory: you tried to allocate 1105920 bytes.的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • RuntimeError: Trying to resize storage that is not resizable

    今天模型訓(xùn)練,遇到了個(gè)bug 先是在dataloder那報(bào)了這樣一個(gè)錯(cuò) RuntimeError: Caught RuntimeError in DataLoader worker process 0. 然后后面報(bào) RuntimeError: Trying to resize storage that is not resizable 完整錯(cuò)誤代碼如下 一開始,在博客上看到是num_works設(shè)置有問題,需要設(shè)置為0 或 和顯卡相同的數(shù) 當(dāng)時(shí),還

    2024年02月02日
    瀏覽(30)
  • git pull報(bào)沒有足夠內(nèi)存 not enough memory for initialization

    git pull報(bào)沒有足夠內(nèi)存 not enough memory for initialization

    ? ? ? ? git clone 或 git pull 批量同步遠(yuǎn)程 git倉庫代碼時(shí),報(bào) 沒有足夠內(nèi)存用于初始化 ? not enough memory for initialization 。經(jīng)過觀察 資源管理器 的內(nèi)存使用情況,發(fā)現(xiàn)為 剩余可用內(nèi)存不足造成的。加物理內(nèi)存麻煩,可通過適當(dāng)調(diào)整? 分頁文件(虛擬內(nèi)存) 最大可用值 解決。 目

    2024年02月16日
    瀏覽(19)
  • mac的M1電腦airtest報(bào)錯(cuò)ImportError: Error importing numpy: you should not try to import numpy from

    mac的M1電腦airtest報(bào)錯(cuò)ImportError: Error importing numpy: you should not try to import numpy from

    執(zhí)行的時(shí)候報(bào)錯(cuò): airtest 報(bào)錯(cuò)ImportError: Error importing numpy: you should not try to import numpy from its source directory; please exit the numpy source tree, and relaunch your python interpreter from there. 還有報(bào)錯(cuò):ImportError: dlopen(/Users/linjing/Library/Python/3.9/lib/python/site-packages/cv2/cv2.abi3.so, 0x0002): tried: ‘/Users/li

    2024年04月11日
    瀏覽(17)
  • 解決報(bào)錯(cuò)ValueError: not enough values to unpack (expected 3, got 2)

    錯(cuò)誤提示: 在使用opencv進(jìn)行關(guān)鍵點(diǎn)識(shí)別、邊緣輪廓提取的時(shí)候,提示以上錯(cuò)誤,報(bào)錯(cuò)原因是函數(shù)定義的返回值數(shù)量和調(diào)用函數(shù)時(shí)實(shí)際賦予的返回值數(shù)量不一致。導(dǎo)致這個(gè)問題,實(shí)際是因?yàn)閛pencv版本不一致引起的,新版opencv(opencv4)在調(diào)用findContours時(shí)只需要兩個(gè)參數(shù),需要?jiǎng)h

    2024年02月11日
    瀏覽(26)
  • RuntimeError: Trying to backward through the graph a second time (or directly access saved variable

    用pytorch的時(shí)候發(fā)生了這個(gè)錯(cuò)誤,寫下來避免以后再次入坑。感謝這次坑讓我對(duì)預(yù)訓(xùn)練模型的使用有了更清楚的認(rèn)識(shí)。 RuntimeError: Trying to backward through the graph a second time (or directly access saved variables after they have already been freed). Saved intermediate values of the graph are freed when you call .bac

    2024年01月16日
    瀏覽(14)
  • check_password 密碼驗(yàn)證拋異常not enough values to unpack (expected 4, got 2)

    check_password 密碼驗(yàn)證拋異常not enough values to unpack (expected 4, got 2)

    Django開發(fā)中進(jìn)行用戶前端輸入的密碼password與數(shù)據(jù)庫中加密后的密碼進(jìn)行密碼驗(yàn)證) .拋異常**not enough values to unpack (expected 4, got 2)** ,定位到check_password(password,user.password) 第一步,首先復(fù)習(xí)相關(guān)方法語法和源碼定義用法 : 加密: make_password (text, None, ‘pbkdf2_sha256’) 驗(yàn)證方法:

    2023年04月09日
    瀏覽(16)
  • Unity “Failed to create agent because it is not close enough to the NavMesh“警告 并由此引發(fā)的問題

    Unity “Failed to create agent because it is not close enough to the NavMesh“警告 并由此引發(fā)的問題

    這個(gè)報(bào)錯(cuò)表示的意思是:NavMeshAgent所在節(jié)點(diǎn)未放置在尋路網(wǎng)格上 從最基本的理解上,就是說你的角色,或者某個(gè) agent 沒有在導(dǎo)航的地形上, 最關(guān)鍵的是:由此引發(fā)的報(bào)錯(cuò): \\\"SetDestination\\\" can only be called on an active agent that has been placed on a NavMesh. 導(dǎo)致角色無法移動(dòng)。 我找了很久

    2024年02月13日
    瀏覽(29)
  • Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8. You can try some of

    Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8. You can try some of

    1、在 Terminal 上輸入命令: gradlew app:dependencies --configuration releaseRuntimeClasspath ,執(zhí)行了: Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.,翻譯: Android Gradle插件需要Java 11才能運(yùn)行。您目前正在使用Java 1.8。 解決問題:如何下載安裝的JDK11 ? ? ? 2、android studio

    2024年02月16日
    瀏覽(24)
  • 報(bào)錯(cuò)記錄torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 90.00 MiB (GPU 0; 7.93 GiB to

    原因,我選的卡號(hào)選錯(cuò)了, 確認(rèn)好兩件事: 1、本地文件和遠(yuǎn)程文件同步好了 2、代碼中有沒有指定哪塊GPU的操作 他這個(gè)報(bào)錯(cuò)很反直覺的一個(gè)地方:如果你指定了2卡,2卡顯存滿了,他會(huì)說0卡顯存滿了,你去看0發(fā)現(xiàn)0根本沒人用,這就很容易被繞進(jìn)去

    2024年02月12日
    瀏覽(22)
  • error: L6236E: No section matches selector - no section to be FIRST/LAST.Not enough information to l

    error: L6236E: No section matches selector - no section to be FIRST/LAST.Not enough information to l

    .ObjectsSTM32_MD.sct(7): error: L6236E: No section matches selector - no section to be FIRST/LAST. Not enough information to list image symbols. Not enough information to list load addresses in the image map. Finished: 2 information, 0 warning and 1 error messages. “.ObjectsSTM32_MD.axf” - 1 Error(s), 0 Warning(s). Target not created. Build Time Elap

    2024年02月15日
    瀏覽(16)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包