Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
e6e36aac
Unverified
提交
e6e36aac
authored
3月 07, 2022
作者:
Glenn Jocher
提交者:
GitHub
3月 07, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update bytes to GB with bitshift (#6886)
上级
acc58c1d
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
11 行增加
和
10 行删除
+11
-10
__init__.py
utils/__init__.py
+3
-4
autobatch.py
utils/autobatch.py
+4
-3
general.py
utils/general.py
+3
-2
torch_utils.py
utils/torch_utils.py
+1
-1
没有找到文件。
utils/__init__.py
浏览文件 @
e6e36aac
...
...
@@ -21,14 +21,13 @@ def notebook_init(verbose=True):
if
is_colab
():
shutil
.
rmtree
(
'/content/sample_data'
,
ignore_errors
=
True
)
# remove colab /sample_data directory
# System info
if
verbose
:
# System info
# gb = 1 / 1000 ** 3 # bytes to GB
gib
=
1
/
1024
**
3
# bytes to GiB
gb
=
1
<<
30
# bytes to GiB (1024 ** 3)
ram
=
psutil
.
virtual_memory
()
.
total
total
,
used
,
free
=
shutil
.
disk_usage
(
"/"
)
display
.
clear_output
()
s
=
f
'({os.cpu_count()} CPUs, {ram
* gib:.1f} GB RAM, {(total - free) * gib:.1f}/{total * gi
b:.1f} GB disk)'
s
=
f
'({os.cpu_count()} CPUs, {ram
/ gb:.1f} GB RAM, {(total - free) / gb:.1f}/{total / g
b:.1f} GB disk)'
else
:
s
=
''
...
...
utils/autobatch.py
浏览文件 @
e6e36aac
...
...
@@ -34,11 +34,12 @@ def autobatch(model, imgsz=640, fraction=0.9, batch_size=16):
LOGGER
.
info
(
f
'{prefix}CUDA not detected, using default CPU batch-size {batch_size}'
)
return
batch_size
gb
=
1
<<
30
# bytes to GiB (1024 ** 3)
d
=
str
(
device
)
.
upper
()
# 'CUDA:0'
properties
=
torch
.
cuda
.
get_device_properties
(
device
)
# device properties
t
=
properties
.
total_memory
/
1024
**
3
# (GiB)
r
=
torch
.
cuda
.
memory_reserved
(
device
)
/
1024
**
3
# (GiB)
a
=
torch
.
cuda
.
memory_allocated
(
device
)
/
1024
**
3
# (GiB)
t
=
properties
.
total_memory
/
gb
# (GiB)
r
=
torch
.
cuda
.
memory_reserved
(
device
)
/
gb
# (GiB)
a
=
torch
.
cuda
.
memory_allocated
(
device
)
/
gb
# (GiB)
f
=
t
-
(
r
+
a
)
# free inside reserved
LOGGER
.
info
(
f
'{prefix}{d} ({properties.name}) {t:.2f}G total, {r:.2f}G reserved, {a:.2f}G allocated, {f:.2f}G free'
)
...
...
utils/general.py
浏览文件 @
e6e36aac
...
...
@@ -223,11 +223,12 @@ def emojis(str=''):
def
file_size
(
path
):
# Return file/dir size (MB)
mb
=
1
<<
20
# bytes to MiB (1024 ** 2)
path
=
Path
(
path
)
if
path
.
is_file
():
return
path
.
stat
()
.
st_size
/
1E6
return
path
.
stat
()
.
st_size
/
mb
elif
path
.
is_dir
():
return
sum
(
f
.
stat
()
.
st_size
for
f
in
path
.
glob
(
'**/*'
)
if
f
.
is_file
())
/
1E6
return
sum
(
f
.
stat
()
.
st_size
for
f
in
path
.
glob
(
'**/*'
)
if
f
.
is_file
())
/
mb
else
:
return
0.0
...
...
utils/torch_utils.py
浏览文件 @
e6e36aac
...
...
@@ -86,7 +86,7 @@ def select_device(device='', batch_size=0, newline=True):
space
=
' '
*
(
len
(
s
)
+
1
)
for
i
,
d
in
enumerate
(
devices
):
p
=
torch
.
cuda
.
get_device_properties
(
i
)
s
+=
f
"{'' if i == 0 else space}CUDA:{d} ({p.name}, {p.total_memory /
1024 ** 2
:.0f}MiB)
\n
"
# bytes to MB
s
+=
f
"{'' if i == 0 else space}CUDA:{d} ({p.name}, {p.total_memory /
(1 << 20)
:.0f}MiB)
\n
"
# bytes to MB
else
:
s
+=
'CPU
\n
'
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论