Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
7473f0f9
Unverified
提交
7473f0f9
authored
11月 12, 2021
作者:
Glenn Jocher
提交者:
GitHub
11月 12, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
DDP `WORLD_SIZE`-safe dataloader workers (#5631)
* WORLD_SIZE-safe workers * Update with DDP comment
上级
d5b21b1e
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
4 行增加
和
3 行删除
+4
-3
train.py
train.py
+2
-2
datasets.py
utils/datasets.py
+2
-1
没有找到文件。
train.py
浏览文件 @
7473f0f9
...
...
@@ -266,7 +266,7 @@ def train(hyp, # path/to/hyp.yaml or hyp dictionary
stopper
=
EarlyStopping
(
patience
=
opt
.
patience
)
compute_loss
=
ComputeLoss
(
model
)
# init loss class
LOGGER
.
info
(
f
'Image sizes {imgsz} train, {imgsz} val
\n
'
f
'Using {train_loader.num_workers} dataloader workers
\n
'
f
'Using {train_loader.num_workers
* WORLD_SIZE
} dataloader workers
\n
'
f
"Logging results to {colorstr('bold', save_dir)}
\n
"
f
'Starting training for {epochs} epochs...'
)
for
epoch
in
range
(
start_epoch
,
epochs
):
# epoch ------------------------------------------------------------------
...
...
@@ -460,7 +460,7 @@ def parse_opt(known=False):
parser
.
add_argument
(
'--single-cls'
,
action
=
'store_true'
,
help
=
'train multi-class data as single-class'
)
parser
.
add_argument
(
'--adam'
,
action
=
'store_true'
,
help
=
'use torch.optim.Adam() optimizer'
)
parser
.
add_argument
(
'--sync-bn'
,
action
=
'store_true'
,
help
=
'use SyncBatchNorm, only available in DDP mode'
)
parser
.
add_argument
(
'--workers'
,
type
=
int
,
default
=
8
,
help
=
'max
imum number of dataloader workers
'
)
parser
.
add_argument
(
'--workers'
,
type
=
int
,
default
=
8
,
help
=
'max
dataloader workers (per RANK in DDP mode)
'
)
parser
.
add_argument
(
'--project'
,
default
=
ROOT
/
'runs/train'
,
help
=
'save to project/name'
)
parser
.
add_argument
(
'--name'
,
default
=
'exp'
,
help
=
'save to project/name'
)
parser
.
add_argument
(
'--exist-ok'
,
action
=
'store_true'
,
help
=
'existing project/name ok, do not increment'
)
...
...
utils/datasets.py
浏览文件 @
7473f0f9
...
...
@@ -34,6 +34,7 @@ from utils.torch_utils import torch_distributed_zero_first
HELP_URL
=
'https://github.com/ultralytics/yolov5/wiki/Train-Custom-Data'
IMG_FORMATS
=
[
'bmp'
,
'jpg'
,
'jpeg'
,
'png'
,
'tif'
,
'tiff'
,
'dng'
,
'webp'
,
'mpo'
]
# acceptable image suffixes
VID_FORMATS
=
[
'mov'
,
'avi'
,
'mp4'
,
'mpg'
,
'mpeg'
,
'm4v'
,
'wmv'
,
'mkv'
]
# acceptable video suffixes
WORLD_SIZE
=
int
(
os
.
getenv
(
'WORLD_SIZE'
,
1
))
# DPP
NUM_THREADS
=
min
(
8
,
os
.
cpu_count
())
# number of multiprocessing threads
# Get orientation exif tag
...
...
@@ -107,7 +108,7 @@ def create_dataloader(path, imgsz, batch_size, stride, single_cls=False, hyp=Non
prefix
=
prefix
)
batch_size
=
min
(
batch_size
,
len
(
dataset
))
nw
=
min
([
os
.
cpu_count
(),
batch_size
if
batch_size
>
1
else
0
,
workers
])
# number of workers
nw
=
min
([
os
.
cpu_count
()
//
WORLD_SIZE
,
batch_size
if
batch_size
>
1
else
0
,
workers
])
# number of workers
sampler
=
torch
.
utils
.
data
.
distributed
.
DistributedSampler
(
dataset
)
if
rank
!=
-
1
else
None
loader
=
torch
.
utils
.
data
.
DataLoader
if
image_weights
else
InfiniteDataLoader
# Use torch.utils.data.DataLoader() if dataset.properties will update during training else InfiniteDataLoader()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论