人工智能深度学习计算机视觉媒体生成视频处理图像处理【免费下载链接】PaddleGANPaddlePaddle GAN library, including lots of interesting applications like First-Order motion transfer, Wav2Lip, picture repair, image editing, photo2cartoon, image style transfer, GPEN, and so on.项目地址https://gitcode.com/gh_mirrors/pa/PaddleGAN点击查看免费下载本文是一份面向 PaddleGAN 开发者的 Benchmark 训练性能测试实战指南。文中以仓库test_tipc/docs/benchmark_train.md为骨架围绕主程序test_tipc/benchmark_train.sh完整讲解从数据准备、环境安装到模型训练、性能日志解析的全流程并结合仓库源码与配置文件逐层拆解参数格式、日志字段与文件组织。读完本文你将掌握如何用一条命令对 PaddleGAN 中任一已接入 TIPC 的模型如 BasicVSR、PP-MSVSR进行多 batch size、多精度、多卡配置的训练性能 Benchmark并读懂生成的 JSON 指标与目录结构。1. Benchmark 训练测试是什么TIPCTraining and Inference Pipeline Certification训推一体认证是飞桨提供的一整套训练—预测打通测试工具。PaddleGAN 仓库的test_tipc/目录下存放了该认证的测试脚本与配置其中Benchmark 预测功能测试的主程序为benchmark_train.sh用于验证并监控模型训练的性能throughput / IPS与收敛性loss。整个测试体系的分工如下详见 test_tipc/README.mdprepare.sh下载并准备测试所需的小型数据集lite 数据与依赖环境benchmark_train.sh读取配置、改写参数、依次执行训练并调用日志解析脚本产出性能指标test_train_inference_python.sh被benchmark_train.sh内部调用的底层训练/推理执行脚本common_func.sh提供func_parser_key、func_parser_value、status_check等通用解析与状态检查函数。从 benchmark_train.sh 开头可以看到脚本在执行前会自动采集环境信息export model_branchgit symbolic-ref HEAD 2/dev/null | cut -d/ -f 3 export model_commit$(git log|head -n1|awk {print $2}) export str_tmp$(echo pip list|grep paddlepaddle-gpu|awk -F {print $2}) export frame_version${str_tmp%%.post*} export frame_commit$(echo ${python} -c import paddle;print(paddle.version.commit))这些model_branch、model_commit、frame_version、frame_commit最终会作为字段写入解析后的日志 JSON 中用于记录本次 Benchmark 的代码版本与飞桨框架版本保证性能数据可回溯。2. 测试流程整个 Benchmark 测试分为两个阶段数据与环境的准备、训练与日志解析。2.1 准备数据和环境安装运行test_tipc/prepare.sh完成训练数据准备和依赖环境安装# 运行格式bash test_tipc/prepare.sh train_benchmark.txt mode bash test_tipc/prepare.sh test_tipc/configs/msvsr/train_infer_python.txt benchmark_train脚本执行逻辑见 prepare.shif [ ${MODE} benchmark_train ];then pip install -r requirements.txt MODElite_train_lite_infer fi即当传入的 mode 为benchmark_train时先安装仓库根目录requirements.txt中声明的依赖随后将 MODE 切回lite_train_lite_infer按模型名model_name走对应的数据下载分支。仓库内置了多个模型的精简数据集下载逻辑例如节选自 prepare.sh模型名下载的数据集Pix2pixpix2pix_facade_lite.tarCycleGANcyclegan_horse2zebra_lite.tarStyleGANv2ffhq_256.tarFOMMfom_lite.taredvr/basicvsr/msvsrreds_lite.tarREDS 精简版esrganDIV2KandSet14paddle.tarswinirswinir_data.zipinvdn/nafnetSIDD_mini.zipsingansingan-official_images.zipGFPGANgfpgan_tipc_data.zipaotganaotgan.zip注意prepare.sh中模式并不局限于benchmark_train还支持lite_train_lite_infer、whole_train_whole_infer、whole_infer、cpp_infer等见 prepare.sh本文聚焦于 Benchmark 场景。2.2 功能测试执行训练与日志解析执行test_tipc/benchmark_train.sh完成模型训练和日志解析# 运行格式bash test_tipc/benchmark_train.sh train_benchmark.txt mode bash test_tipc/benchmark_train.sh test_tipc/configs/msvsr/train_infer_python.txt benchmark_train脚本首先将传入的配置文件复制为./test_tipc/benchmark_train.txt作为工作副本见 benchmark_train.shFILENAME$1 # copy FILENAME as new new_filename./test_tipc/benchmark_train.txt cmdyes|cp $FILENAME $new_filename FILENAME$new_filename随后解析配置中的train_benchmark_params小节取出batch_size候选列表、fp_items精度列表、total_itersepoch/迭代数、--profiler_options性能剖析参数以及flags环境变量并通过eval export的方式设置 FLAGS见 benchmark_train.sh。2.3 只运行某一个训练配置benchmark_train.sh支持通过第三个参数只运行某一个训练配置# 运行格式bash test_tipc/benchmark_train.sh train_benchmark.txt mode bash test_tipc/benchmark_train.sh test_tipc/configs/msvsr/train_infer_python.txt benchmark_train dynamic_bs4_fp32_DP_N1C1dynamic_bs4_fp32_DP_N1C1为传入的第三个参数格式为${modeltype}_${batch_size}_${fp_item}_${run_mode}_${device_num}包含的信息有modeltype模型类型如dynamic动态图训练传dynamicTostatic时还会触发动转静逻辑batch_sizebatch size 大小fp_item训练精度如fp32、fp16run_mode分布式运行模式如DPData Parallel 数据并行device_num分布式训练使用的机器信息如N1C1表示单机单卡、N1C4表示单机四卡。对应的解析逻辑位于 benchmark_train.sh# parser params from input: modeltype_bs${bs_item}_${fp_item}_${run_mode}_${device_num} IFS_ params_list(${PARAMS}) model_type${params_list[0]} batch_size${params_list[1]} batch_sizeecho ${batch_size} | tr -cd [0-9] precision${params_list[2]} run_mode${params_list[3]} device_num${params_list[4]} ... if [ ${precision} null ];then precisionfp32 fi值得注意的细节batch_size会通过tr -cd [0-9]过滤掉非数字字符例如bs4会被提取为4precision如果传null则默认回退为fp32。此外脚本还支持两个特殊的第三参数取值见 benchmark_train.sh不传第三参数默认按配置中的batch_size、fp_items全列表执行device_num_list(N1C4)run_modeDP传dynamicTostatic同样全列表执行并且会通过sed -i s/trainer:norm_train/trainer:to_static_train/g将配置中的训练器替换为动转静训练器日志名中会加入d2sT_前缀见 benchmark_train.sh。3. Benchmark 配置文件详解Benchmark 参数并不是随意传入的而是以小节train_benchmark_params的形式定义在 TIPC 配置文件中。以 test_tipc/configs/msvsr/train_infer_python.txt 为例train_benchmark_params batch_size:2|4 fp_items:fp32|fp16 total_iters:60 --profiler_options:batch_range[10,20];stateGPU;tracer_optionDefault;profile_pathmodel.profile flags:FLAGS_cudnn_exhaustive_search1再以 test_tipc/configs/basicvsr/train_infer_python.txt 为例train_benchmark_params batch_size:2|4 fp_items:fp32 total_iters:50 --profiler_options:batch_range[10,20];stateGPU;tracer_optionDefault;profile_pathmodel.profile flags:FLAGS_cudnn_exhaustive_search1各字段含义如下字段含义取值示例batch_sizebatch size 候选列表用|分隔脚本会逐个遍历执行2\|4fp_items训练精度候选列表用|分隔fp32\|fp16total_itersBenchmark 训练的总迭代数在该模式下替代常规训练的 epoch 数60、50--profiler_options传给训练脚本的 profiler 配置batch_range指定性能剖析的迭代区间state指定采集状态如 GPUtracer_option指定追踪选项profile_path指定剖析输出文件batch_range[10,20];stateGPU;...flags需要导出的环境变量多个用;分隔FLAGS_cudnn_exhaustive_search1关于文档中提到的 test_tipc/configs/basicvsr/train_benchmark.txt仓库内实际存在的配置文件名是test_tipc/configs/basicvsr/train_infer_python.txttrain_benchmark.txt是文档笔误或早期命名实际运行时应使用train_infer_python.txt这一点在prepare.sh与benchmark_train.sh的调用示例中均以train_infer_python.txt为准。4. 训练执行的底层调用链benchmark_train.sh自身并不直接发起训练而是通过bash test_tipc/test_train_inference_python.sh ${FILENAME} benchmark_train来执行见 benchmark_train.sh。在执行前脚本会用func_sed_params对工作副本配置文件做多处定点改写见 benchmark_train.sh行号常量作用line_python3将 python 解释器替换为脚本使用的pythonline_gpuid4设置 GPU 编号单卡写0多卡写由set_gpu_id计算的卡序line_precision6设置精度fp32/fp16line_epoch7设置迭代数line_batchsize9设置 batch sizeline_profile13设置/清空--profiler_optionsline_eval_py24在 Benchmark 模式下将 eval 置为null不做评估line_export_py30在 Benchmark 模式下将 export 置为null不导出模型set_gpu_id函数负责把N1C4这类描述换算成具体的 CUDA 卡序见 benchmark_train.sh取字符串第 2~7 位解析出机器数M与卡数P计算gpu_num (P - 1) / M再生成seq -s , 0 $gpu_num形式的卡列表若结果只有一张卡${#gpu_id} -le 1则走单卡分支。最终在test_train_inference_python.sh中训练命令会根据卡数拼接见 test_train_inference_python.shif [ ${#gpu} -le 2 ];then # train with cpu or single gpu cmd${python} ${run_train} ${set_use_gpu} ${set_save_model} ${set_epoch} ${set_pretrain} ${set_batchsize} ${set_amp_config} ${set_amp_level} ${set_train_params1} elif [ ${#ips} -le 26 ];then # train with multi-gpu cmd${python} -m paddle.distributed.launch --gpus${gpu} ${run_train} ... else # train with multi-machine cmd${python} -m paddle.distributed.launch --ips${ips} --gpus${gpu} ${run_train} ... fi其中run_train即配置文件中norm_train行的内容例如 MSVSR 的训练入口为norm_train:tools/main.py -c configs/msvsr_reds.yaml --seed 123 -o log_config.interval1 snapshot_config.interval5 dataset.train.dataset.num_frames15即最终以tools/main.py加载configs/msvsr_reds.yaml并通过-o覆盖训练间隔、快照间隔与帧数等配置。混合精度场景下autocastfp16脚本还会追加--amp --amp_levelO2见 test_train_inference_python.sh。5. 日志输出与 JSON 指标解析5.1 训练日志解析示例运行结束后脚本会调用日志解析脚本analysis.py对训练日志做结构化解析见 benchmark_train.sh${python} ${BENCHMARK_ROOT}/scripts/analysis.py --filename ${log_path}/${log_name} \ --speed_log_file ${speed_log_path}/${speed_log_name} \ --model_name ${_model_name} \ --base_batch_size ${batch_size} \ --run_mode ${run_mode} \ --fp_item ${precision} \ --keyword ips: \ --skip_steps 2 \ --device_num ${device_num} \ --speed_unit samples/s \ --convergence_key loss:参数含义--filename待解析的训练日志路径--speed_log_file解析出的速度指标写入的 speed 日志文件--keyword ips:从日志中抽取速度指标时匹配的关键字--skip_steps 2跳过前 2 个 step预热步不计入吞吐统计--convergence_key loss:收敛性指标关键字用于提取 loss 作为收敛值--speed_unit速度单位单卡场景为samples/s多卡场景为images/s见 benchmark_train.sh。以 test_tipc/configs/basicvsr/train_infer_python.txt 参数文件为例其训练日志解析结果为一条 JSON{model_branch: dygaph, model_commit: 7c39a1996b19087737c05d883fd346d2f39dbcc0, model_name: basicvsr_bs4_fp32_SingleP_DP, batch_size: 4, fp_item: fp32, run_process_type: SingleP, run_mode: DP, convergence_value: 5.413110, convergence_key: loss:, ips: 19.333, speed_unit: samples/s, device_num: N1C1, model_run_time: 0, frame_commit: 8cc09552473b842c651ead3b9848d41827a3dbab, frame_version: 0.0.0}JSON 各字段释义字段含义model_branch仓库 git 分支脚本开头由git symbolic-ref获取model_commit仓库 git commitgit log首行model_name由模型名_bs${batch_size}_${precision}_${run_mode}拼接而成batch_size本次运行的 batch sizefp_item训练精度run_process_type/run_mode运行方式单卡为SingleP与并行模式DPconvergence_value/convergence_key收敛值与其在日志中的关键字此处为loss:ips每秒处理的样本数/图像数即核心吞吐指标speed_unit吞吐单位samples/s或images/sdevice_num设备规模描述N1C1、N1C4model_run_time本次训练实际耗时由job_et - job_bt计算frame_commit/frame_version飞桨框架的 commit 与版本号5.2 日志目录结构训练日志和日志解析结果保存在benchmark_log目录下默认目录为当前工作目录可通过环境变量BENCHMARK_LOG_DIR覆盖见 benchmark_train.sh。文件组织格式如下train_log/ ├── index │ ├── PaddleGAN_msvsr_bs4_fp32_SingleP_DP_N1C1_speed │ └── PaddleGAN_msvsr_bs4_fp32_SingleP_DP_N1C4_speed ├── profiling_log │ └── PaddleGAN_msvsr_bs4_fp32_SingleP_DP_N1C1_profiling └── train_log ├── PaddleGAN_msvsr_bs4_fp32_SingleP_DP_N1C1_log └── PaddleGAN_msvsr_bs4_fp32_MultiP_DP_N1C4_log日志命名规则为${repo_name}_${model_name}_bs${batch_size}_${precision}_${run_mode}_${device_num}_${to_static}${类型后缀}见 benchmark_train.sh其中_log原始训练日志来自test_train_inference_python.sh的标准输出重定向_speed解析出的速度指标文件_profilingprofiler 运行日志仅当 profiler 开启时产生。此外benchmark_log/results.log会记录每条命令执行成功或失败的汇总状态其判定依赖 common_func.sh 中的status_check退出码为 0 时打印 Run successfully否则打印 Run failed。5.3 性能剖析Profiling脚本默认开启 profiling环境变量PROFILING_TIMER_ONLY默认值为True见 benchmark_train.sh单卡模式下会先执行一次带 profiler 的训练cmdtimeout 5m bash test_tipc/test_train_inference_python.sh ${FILENAME} benchmark_train ${log_path}/${log_name} 21 profiler 配置来自配置文件的--profiler_options行例如batch_range[10,20]表示只剖析第 10~20 个 batch。若设置PROFILING_TIMER_ONLYFalseprofiler 会追加timer_onlyFalse输出更详细的耗时设置为no则完全跳过 profiling 阶段见 benchmark_train.sh。6. 与常规训推一体测试的关系benchmark_train.sh是 TIPC 测试家族中专用于性能 Benchmark 的一环。与之并行的还有test_tipc/test_train_inference_python.sh训练—预测基本功能测试支持lite_train_lite_infer、whole_train_whole_infer等模式test_tipc/test_inference_cpp.sh基于 C 的推理测试详见 test_tipc/docs/test_inference_cpp.mdtest_tipc/compare_results.py将预测结果与 test_tipc/results 下预存结果比对判断精度是否在误差范围内。二者的核心差异在于常规测试关注功能是否打通、精度是否对齐而benchmark_train关注训练吞吐与收敛速度因此它会关闭 eval 与 export 环节line_eval_py24、line_export_py30被替换为null只保留纯训练耗时测量。仓库 test_tipc/results/python_basicvsr_results_fp32.txt 中预存的Metric psnr: 27.0864、Metric ssim: 0.7835即是常规测试中用于精度比对的基准结果属于功能验证而非 Benchmark 产物。7. 使用注意事项小结综合原文档与源码实现实际使用时有以下几点值得注意先 prepare 后 benchmark必须按顺序先运行prepare.sh数据下载 pip install -r requirements.txt再运行benchmark_train.sh否则会因缺少数据集或依赖而失败。配置文件路径以train_infer_python.txt为准仓库中实际配置文件名后缀为train_infer_python.txt示例命令中的train_benchmark.txt应替换为前者。第三参数不传时默认全量跑会遍历配置中所有batch_size与fp_items组合耗时较长需要单独验证某个配置时务必带上形如dynamic_bs4_fp32_DP_N1C1的参数。动转静场景传dynamicTostatic会自动把norm_train训练器替换为to_static_train并加d2sT_日志前缀可用于对比动态图与静态图训练性能。日志目录可定制通过BENCHMARK_LOG_DIR环境变量可改变benchmark_log的输出位置。profiling 可通过环境变量控制PROFILING_TIMER_ONLYno可跳过剖析False则输出更细粒度耗时适用于不同深度的性能分析需求。赞分享人工智能深度学习计算机视觉媒体生成视频处理图像处理【免费下载链接】PaddleGANPaddlePaddle GAN library, including lots of interesting applications like First-Order motion transfer, Wav2Lip, picture repair, image editing, photo2cartoon, image style transfer, GPEN, and so on.项目地址https://gitcode.com/gh_mirrors/pa/PaddleGAN点击查看免费下载相关推荐PaddleOCR 训练 Benchmark 测试完全指南基于 TIPC 的 Linux 端训练性能监控方案PaddleOCR 训练 Benchmark 测试完全指南基于 TIPC 的 Linux 端训练性能监控方案 本篇技术指南聚焦 PaddleOCR 仓库中 T人工智能计算机视觉OCR深度学习大模型RAG香山处理器 XSNoCTop片上网络的 5 个可查证设计决策香山处理器 XSNoCTop片上网络的 5 个可查证设计决策 香山处理器XiangShan是一个开源 RISC V 高性能核心。当它被放进多核 SoC 时硬件开发指令集高性能计算PaddleDetection TIPC Benchmark 训练性能测试全指南从准备到日志解析PaddleDetection TIPC Benchmark 训练性能测试全指南从准备到日志解析 导读 本文聚焦 PaddleDetection 仓库中 T人工智能深度学习计算机视觉上一篇sssnic-driver高级功能3SNIC以太网控制器高级配置详解下一篇WebToApp 内建 Agent 深度解析手机端基于工具调用的全功能自动化助手创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
