YOLOv5本地模型训练报错解决

news/2025/2/12 16:42:08/

报错解决

页面文件太小,无法完成操作

训练过程中,发生下图所示的报错,同时pycharm崩溃

在这里插入图片描述

1. 更改虚拟内存

  1. 进入高级系统设置,应该都会进,就不说过程了

在这里插入图片描述

  1. 设置虚拟内存大小

在这里插入图片描述

2. 减小占用内容大小

  1. 新建一个fixNvPe.py程序
# Simple script to disable ASLR and make .nv_fatb sections read-only
# Requires: pefile  ( python -m pip install pefile )
# Usage:  fixNvPe.py --input path/to/*.dllimport argparse
import pefile
import glob
import os
import shutildef main(args):failures = []for file in glob.glob( args.input, recursive=args.recursive ):print(f"\n---\nChecking {file}...")pe = pefile.PE(file, fast_load=True)nvbSect = [ section for section in pe.sections if section.Name.decode().startswith(".nv_fatb")]if len(nvbSect) == 1:sect = nvbSect[0]size = sect.Misc_VirtualSizeaslr = pe.OPTIONAL_HEADER.IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASEwritable = 0 != ( sect.Characteristics & pefile.SECTION_CHARACTERISTICS['IMAGE_SCN_MEM_WRITE'] )print(f"Found NV FatBin! Size: {size/1024/1024:0.2f}MB  ASLR: {aslr}  Writable: {writable}")if (writable or aslr) and size > 0:print("- Modifying DLL")if args.backup:bakFile = f"{file}_bak"print(f"- Backing up [{file}] -> [{bakFile}]")if os.path.exists( bakFile ):print( f"- Warning: Backup file already exists ({bakFile}), not modifying file! Delete the 'bak' to allow modification")failures.append( file )continuetry:shutil.copy2( file, bakFile)except Exception as e:print( f"- Failed to create backup! [{str(e)}], not modifying file!")failures.append( file )continue# Disable ASLR for DLL, and disable writing for sectionpe.OPTIONAL_HEADER.DllCharacteristics &= ~pefile.DLL_CHARACTERISTICS['IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE']sect.Characteristics = sect.Characteristics & ~pefile.SECTION_CHARACTERISTICS['IMAGE_SCN_MEM_WRITE']try:newFile = f"{file}_mod"print( f"- Writing modified DLL to [{newFile}]")pe.write( newFile )pe.close()print( f"- Moving modified DLL to [{file}]")os.remove( file )shutil.move( newFile, file )except Exception as e:print( f"- Failed to write modified DLL! [{str(e)}]")failures.append( file )continueprint("\n\nDone!")if len(failures) > 0:print("***WARNING**** These files needed modification but failed: ")for failure in failures:print( f" - {failure}")def parseArgs():parser = argparse.ArgumentParser( description="Disable ASLR and make .nv_fatb sections read-only", formatter_class=argparse.ArgumentDefaultsHelpFormatter )parser.add_argument('--input', help="Glob to parse", default="*.dll")parser.add_argument('--backup', help="Backup modified files", default=True, required=False)parser.add_argument('--recursive', '-r', default=False, action='store_true', help="Recurse into subdirectories")return parser.parse_args()###############################
# program entry point
#
if __name__ == "__main__":args = parseArgs()main( args )
  1. 安装pefile
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pefile

在这里插入图片描述

  1. 终端运行fixNvPe.py文件
python fixNvPe.py --input E:\kaifa\Anaconda3\envs\yolov5\lib\site-packages\torch\lib\cudnn_adv_infer64_8.dll

intput后面的路径,就是报错那里,后面给的路径

出现下图所示表示执行完毕

在这里插入图片描述

RuntimeError: CUDA out of memory.

解决方式:

换小模型

在这里插入图片描述

AttributeError: ‘FreeTypeFont’ object has no attribute ‘getsize’

在这里插入图片描述

这是因为安装了新版本的 Pillow (10),pip install tf-models-official删除了该getsize 功能,降级到 Pillow 9.5 解决了该问题

解决方式:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple Pillow==9.5

http://www.ppmy.cn/news/1007845.html

相关文章

C语言基础知识点一

C语言基础知识点一&#xff1a; 1.数据类型 2.bool类型&#xff1a; 使用bool时时&#xff0c;需要增加<stdbool.h>头文件。 说明&#xff1a;bool 类型只有非零&#xff08;true&#xff09;和零&#xff08;false&#xff09;两种值。 如: if&#xff08;-1&#xf…

如何把非1024的采样数放入aac编码器

一. aac对数据规格要求 二、代码实现 1.初始化 2.填入数据 3.取数据 三.图解 一. aac对放入的采样数要求 我们知道aac每次接受的字节数是固定的&#xff0c;在之前的文章里有介绍libfdk_aac音频采样数和编码字节数注意 它支持的采样数和编码字节数分别是&#xff1a; fdk_aac …

C语言假期作业 DAY 13

一、选择题 1、如果 x2014 &#xff0c;下面函数的返回值是&#xff08; &#xff09; int fun(unsigned int x) { int n 0; while(x 1) { n; x x | (x 1); } return n; } A: 20 B: 21 C: 23 D 25 答案解析 正确答案&#xff1a;C 这个作用是对整型中0的个数进行统计&…

什么是图像特征?如何让计算机理解图像特征?

图像的特征 大多数人都玩过拼图游戏。首先拿到完整图像的碎片&#xff0c;然后把这些碎片以正确的方式排列起来从而重建这幅图像。如果把拼图游戏的原理写成计算机程序&#xff0c;那计算机就也会玩拼图游戏了。 在拼图时&#xff0c;我们要寻找一些唯一的特征&#xff0c;这…

第5章 通过微信网页授权间接获取微信中的code值

1 准备基于外网的有效回调页面 由于当前最新版的微信不再显示带有code值的错误页面&#xff0c;所以开发者必须先自己构建1个用于获取code值外网的有效回调页面&#xff0c;微信浏览器才能通过该有效回调页面获取code值。 上面的页面在最新版的微信不再显示。 1.1 构建基于外网…

DSP定点数的计算规则和示例

目录 1. Q/S表示法的数值范围 2. 定点化加减法计算规则 2.1 防溢出处理 3. 定点化乘法计算规则 3.1 推算 4. 定点化除法计算规则 4.1 推算 5. 程序代码中如何确定Q值 6. 浮点转定点计算示例 1. Q/S表示法的数值范围 Q表示法 S表示法 数的范围 Q15 S0.15 -1≤X≤0…

分治法、回溯法与动态规划

算法思想比较 回溯法&#xff1a;有“通用解题法”之称&#xff0c;用它可以系统地搜索问题的所有解。回溯法是按照深度优先搜索(DFS)的策略&#xff0c;从根结点出发深度探索解空间树分治法&#xff1a;将一个难以直接解决的大问题&#xff0c;分割成一些规模较小的相同问题&…

SpringBoot实现数据库读写分离

SpringBoot实现数据库读写分离 参考博客https://blog.csdn.net/qq_31708899/article/details/121577253 实现原理&#xff1a;翻看AbstractRoutingDataSource源码我们可以看到其中的targetDataSource可以维护一组目标数据源(采用map数据结构)&#xff0c;并且做了路由key与目标…