首页
常用链接
关于
Search
1
Pytorch DDP
2,093 阅读
2
Pytorch 常见问题
1,210 阅读
3
视频时序切分
854 阅读
4
Semi-Supervised + Noisy Label
747 阅读
5
中文场景下的CLIP图文预训练
738 阅读
阅读
论文阅读
多模态理解
计算机视觉
Video Understanding
Segmentation
AIGC
机器学习
编程开发
C++
Python
LeetCode
Shell
Pytorch
模型加速
广告
广告基础知识
推荐算法
创意优选
购房/投资
职场经验复盘
默认分类
Search
标签搜索
python
Pandas
transformer
视觉传统方法
创意质量
git
shell
视频理解
Pytroch
nlp
DDP
图像自监督预训练
安装包
视频流行度
Jefxiong
累计撰写
50
篇文章
累计收到
7
条评论
首页
栏目
阅读
论文阅读
多模态理解
计算机视觉
Video Understanding
Segmentation
AIGC
机器学习
编程开发
C++
Python
LeetCode
Shell
Pytorch
模型加速
广告
广告基础知识
推荐算法
创意优选
购房/投资
职场经验复盘
默认分类
页面
常用链接
关于
搜索到
2
篇与
Pytorch
的结果
2022-02-19
Pytorch DDP
1. Pytorch DDP 使用大致流程 使用 torch.distributed.init_process_group 初始化进程组 使用 torch.nn.parallel.DistributedDataParallel 创建 分布式模型 使用 torch.utils.data.distributed.DistributedSampler 创建 DataLoader 2. Pytorch DDP 训练报错信息 [W reducer.cpp:346] Warning: Grad strides do not match bucket view strides. This may indicate grad was not created according to the gradient layout contract, or that the param's strides changed since DDP was constructed. This is not an error, but may impair performance. Expected to mark a variable ready only once. RuntimeError: Expected to have finished reduction in the prior iteration before starting a new one. 3. DDP多卡训练需要主要事项? 为每个进程设置不同的随机种子 使用syncBN DistributedSampler 多进程的日志管理,文件创建管理,目录创建管理等 4. DDP 单机多卡卡住问题(hang/stuck/dead lock) 现象: GPU利用率100%,但是程序一直没有输出。 (1) 限制单进程并发数(无效) torch.set_num_threads(4) (2) 设置find_unused_parameters为True model = torch.nn.parallel.DistributedDataParallel(model, device_ids=[int(args.local_rank)], output_device=int(args.local_rank), find_unused_parameters=True) # find_unused_parameters 的含义: 查找未用于计算损失的参数 (3) 排查NCCL问题? # 设置环境变量,看是否有更多的信息输出,更多环境变量参考 # https://docs.nvidia.com/deeplearning/nccl/user-guide/docs/env.html export NCCL_DEBUG=INFO export NCCL_DEBUG_SUBSYS=ALL (4) 在不同GPU上,部分分支的输出结果未参与损失计算 报错信息: RuntimeError: Expected to have finished reduction in the prior iteration before starting a new one. 由于过滤了样本,只有当样本满足一定条件下才计算损失(比如回归任务中,只有当pred与gt在一定范围内才计算损失),会导致不同GPU上,缺少梯度计算,导致导致程序假死 参考文献 Pytorch官方文档 Pytorch官方教程 Pytorch多gpu并行训练教程 DDP系列第一篇:入门教程 DDP系列第二篇:实现原理与源代码解析 DDP系列第三篇:实战与技巧 pytorch 多机多卡卡住问题汇总 PyTorch 源码解读之 DP & DDP:模型并行和分布式训练解析 https://discuss.pytorch.org/t/distributed-data-parallel-freezes-without-error-message/8009
2022年02月19日
2,093 阅读
1 评论
3 点赞
2021-05-23
Pytorch 常见问题
1.CUDA_VISIBLE_DEVICES设置无效,始终占用GPU0? 1. 在import torch前设置环境变量 2. CUDA_DEVICE_ORDER=PCI_BUS_ID CUDA_VISIBLE_DEVICES=3 python train.py 2.RuntimeError: CUDA error: device-side assert triggered 设置环境变量,让报错显示更具体的代码行 import os os.environ["CUDA_LAUNCH_BLOCKING"] = "1" 3.RuntimeError: DataLoader worker (pid xxx) is killed by signal: Aborted. what(): CUDA error: initialization error pytorch github issue ref google找到的文章,大多怀疑是内存问题 尝试修改pin_memory没有效用 尝试修改shm没有效果,mount -o remount,size=32g /dev/shm 尝试改小num_worker无效果(16->8)将num_workers设置为0可以解决问题,但肯定不是最优解!!! 4.resume training时,出现GPU OOM的问题 在DDP训练场景下进行resume training可能出现该问题,原因在于每个进程torch.load都加载在同一块卡上,导致最后OOM。解决方案: map_location指定加载在哪块卡上 checkpoint = torch.load(checkpoint_path, map_location='cuda:{}'.format(opts.local_rank)) 5.CUDNN和pytorch版本不匹配 可以从torch_stable.html下载安装 6 . unrecognized arguments: --local_rank,由于torch2.0升级导致,修复方案: python -m torch.distributed.launch xxx 替换为 torchrun xxx
2021年05月23日
1,210 阅读
0 评论
6 点赞
粤ICP备2021042327号