Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
d1c74b39
M
models
项目概览
PaddlePaddle
/
models
接近 2 年 前同步成功
通知
230
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d1c74b39
编写于
12月 12, 2019
作者:
L
LielinJiang
提交者:
Lv Mengsi
12月 12, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix get cuda device bug when only use cpu (#4066)
* fix get cuda device bug when only use cpu * fix typo
上级
0dfd43a2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
15 addition
and
6 deletion
+15
-6
PaddleCV/deeplabv3+/train.py
PaddleCV/deeplabv3+/train.py
+6
-6
PaddleCV/deeplabv3+/utility.py
PaddleCV/deeplabv3+/utility.py
+9
-0
未找到文件。
PaddleCV/deeplabv3+/train.py
浏览文件 @
d1c74b39
...
@@ -164,7 +164,7 @@ total_step = args.total_step
...
@@ -164,7 +164,7 @@ total_step = args.total_step
with
fluid
.
program_guard
(
tp
,
sp
):
with
fluid
.
program_guard
(
tp
,
sp
):
if
args
.
use_py_reader
:
if
args
.
use_py_reader
:
batch_size_each
=
batch_size
//
fluid
.
core
.
get_cuda
_device_count
()
batch_size_each
=
batch_size
//
utility
.
get
_device_count
()
py_reader
=
fluid
.
layers
.
py_reader
(
capacity
=
64
,
py_reader
=
fluid
.
layers
.
py_reader
(
capacity
=
64
,
shapes
=
[[
batch_size_each
,
3
]
+
image_shape
,
[
batch_size_each
]
+
image_shape
],
shapes
=
[[
batch_size_each
,
3
]
+
image_shape
,
[
batch_size_each
]
+
image_shape
],
dtypes
=
[
'float32'
,
'int32'
])
dtypes
=
[
'float32'
,
'int32'
])
...
@@ -197,7 +197,7 @@ with fluid.program_guard(tp, sp):
...
@@ -197,7 +197,7 @@ with fluid.program_guard(tp, sp):
exec_strategy
=
fluid
.
ExecutionStrategy
()
exec_strategy
=
fluid
.
ExecutionStrategy
()
exec_strategy
.
num_threads
=
fluid
.
core
.
get_cuda
_device_count
()
exec_strategy
.
num_threads
=
utility
.
get
_device_count
()
exec_strategy
.
num_iteration_per_drop_scope
=
100
exec_strategy
.
num_iteration_per_drop_scope
=
100
build_strategy
=
fluid
.
BuildStrategy
()
build_strategy
=
fluid
.
BuildStrategy
()
if
args
.
memory_optimize
:
if
args
.
memory_optimize
:
...
@@ -225,11 +225,11 @@ else:
...
@@ -225,11 +225,11 @@ else:
binary
=
fluid
.
compiler
.
CompiledProgram
(
tp
)
binary
=
fluid
.
compiler
.
CompiledProgram
(
tp
)
if
args
.
use_py_reader
:
if
args
.
use_py_reader
:
assert
(
batch_size
%
fluid
.
core
.
get_cuda
_device_count
()
==
0
)
assert
(
batch_size
%
utility
.
get
_device_count
()
==
0
)
def
data_gen
():
def
data_gen
():
batches
=
dataset
.
get_batch_generator
(
batches
=
dataset
.
get_batch_generator
(
batch_size
//
fluid
.
core
.
get_cuda
_device_count
(),
batch_size
//
utility
.
get
_device_count
(),
total_step
*
fluid
.
core
.
get_cuda
_device_count
(),
total_step
*
utility
.
get
_device_count
(),
use_multiprocessing
=
args
.
use_multiprocessing
,
num_workers
=
args
.
num_workers
)
use_multiprocessing
=
args
.
use_multiprocessing
,
num_workers
=
args
.
num_workers
)
for
b
in
batches
:
for
b
in
batches
:
yield
b
[
0
],
b
[
1
]
yield
b
[
0
],
b
[
1
]
...
@@ -266,7 +266,7 @@ print("Training done. Model is saved to", args.save_weights_path)
...
@@ -266,7 +266,7 @@ print("Training done. Model is saved to", args.save_weights_path)
save_model
()
save_model
()
if
args
.
enable_ce
:
if
args
.
enable_ce
:
gpu_num
=
fluid
.
core
.
get_cuda
_device_count
()
gpu_num
=
utility
.
get
_device_count
()
print
(
"kpis
\t
each_pass_duration_card%s
\t
%s"
%
print
(
"kpis
\t
each_pass_duration_card%s
\t
%s"
%
(
gpu_num
,
total_time
/
epoch_idx
))
(
gpu_num
,
total_time
/
epoch_idx
))
print
(
"kpis
\t
train_loss_card%s
\t
%s"
%
(
gpu_num
,
train_loss
))
print
(
"kpis
\t
train_loss_card%s
\t
%s"
%
(
gpu_num
,
train_loss
))
PaddleCV/deeplabv3+/utility.py
浏览文件 @
d1c74b39
...
@@ -78,3 +78,12 @@ def check_gpu(use_gpu):
...
@@ -78,3 +78,12 @@ def check_gpu(use_gpu):
sys
.
exit
(
1
)
sys
.
exit
(
1
)
except
Exception
as
e
:
except
Exception
as
e
:
pass
pass
def
get_device_count
():
try
:
device_num
=
max
(
fluid
.
core
.
get_cuda_device_count
(),
1
)
except
:
device_num
=
1
return
device_num
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录