Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSeg
提交
3a40055a
P
PaddleSeg
项目概览
PaddlePaddle
/
PaddleSeg
通知
285
Star
8
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
53
列表
看板
标记
里程碑
合并请求
3
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleSeg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
53
Issue
53
列表
看板
标记
里程碑
合并请求
3
合并请求
3
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
3a40055a
编写于
8月 19, 2020
作者:
C
chenguowei01
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dump environment info
上级
d72fb677
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
126 addition
and
3 deletion
+126
-3
dygraph/infer.py
dygraph/infer.py
+1
-1
dygraph/train.py
dygraph/train.py
+7
-1
dygraph/utils/__init__.py
dygraph/utils/__init__.py
+1
-0
dygraph/utils/get_environ_info.py
dygraph/utils/get_environ_info.py
+116
-0
dygraph/val.py
dygraph/val.py
+1
-1
未找到文件。
dygraph/infer.py
浏览文件 @
3a40055a
...
...
@@ -84,7 +84,7 @@ def parse_args():
def
main
(
args
):
env_info
=
get_environ_info
()
places
=
fluid
.
CUDAPlace
(
ParallelEnv
().
dev_id
)
\
if
env_info
[
'
place'
]
==
'cuda'
and
fluid
.
is_compiled_with_cuda
()
\
if
env_info
[
'
Paddle compiled with cuda'
]
and
env_info
[
'GPUs used'
]
\
else
fluid
.
CPUPlace
()
if
args
.
dataset
not
in
DATASETS
:
...
...
dygraph/train.py
浏览文件 @
3a40055a
...
...
@@ -21,6 +21,7 @@ from dygraph.datasets import DATASETS
import
dygraph.transforms
as
T
from
dygraph.models
import
MODELS
from
dygraph.utils
import
get_environ_info
from
dygraph.utils
import
logger
from
dygraph.core
import
train
...
...
@@ -129,8 +130,13 @@ def parse_args():
def
main
(
args
):
env_info
=
get_environ_info
()
info
=
[
'{}: {}'
.
format
(
k
,
v
)
for
k
,
v
in
env_info
.
items
()]
info
=
'
\n
'
.
join
([
'
\n
'
,
format
(
'Environment Information'
,
'-^48s'
)]
+
info
+
[
'-'
*
48
])
logger
.
info
(
info
)
places
=
fluid
.
CUDAPlace
(
ParallelEnv
().
dev_id
)
\
if
env_info
[
'
place'
]
==
'cuda'
and
fluid
.
is_compiled_with_cuda
()
\
if
env_info
[
'
Paddle compiled with cuda'
]
and
env_info
[
'GPUs used'
]
\
else
fluid
.
CPUPlace
()
if
args
.
dataset
not
in
DATASETS
:
...
...
dygraph/utils/__init__.py
浏览文件 @
3a40055a
...
...
@@ -17,3 +17,4 @@ from . import download
from
.metrics
import
ConfusionMatrix
from
.utils
import
*
from
.timer
import
Timer
,
calculate_eta
from
.get_environ_info
import
get_environ_info
dygraph/utils/get_environ_info.py
0 → 100644
浏览文件 @
3a40055a
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
os
import
sys
from
collections
import
OrderedDict
import
subprocess
import
glob
import
paddle
import
paddle.fluid
as
fluid
import
cv2
IS_WINDOWS
=
sys
.
platform
==
'win32'
def
_find_cuda_home
():
'''Finds the CUDA install path. It refers to the implementation of
pytorch <https://github.com/pytorch/pytorch/blob/master/torch/utils/cpp_extension.py>.
'''
# Guess #1
cuda_home
=
os
.
environ
.
get
(
'CUDA_HOME'
)
or
os
.
environ
.
get
(
'CUDA_PATH'
)
if
cuda_home
is
None
:
# Guess #2
try
:
which
=
'where'
if
IS_WINDOWS
else
'which'
nvcc
=
subprocess
.
check_output
([
which
,
'nvcc'
]).
decode
().
rstrip
(
'
\r\n
'
)
cuda_home
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
nvcc
))
except
Exception
:
# Guess #3
if
IS_WINDOWS
:
cuda_homes
=
glob
.
glob
(
'C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v*.*'
)
if
len
(
cuda_homes
)
==
0
:
cuda_home
=
''
else
:
cuda_home
=
cuda_homes
[
0
]
else
:
cuda_home
=
'/usr/local/cuda'
if
not
os
.
path
.
exists
(
cuda_home
):
cuda_home
=
None
return
cuda_home
def
_get_nvcc_info
(
cuda_home
):
if
cuda_home
is
not
None
and
os
.
path
.
isdir
(
cuda_home
):
try
:
nvcc
=
os
.
path
.
join
(
cuda_home
,
'bin/nvcc'
)
nvcc
=
subprocess
.
check_output
(
"{} -V"
.
format
(
nvcc
),
shell
=
True
).
decode
()
nvcc
=
nvcc
.
strip
().
split
(
'
\n
'
)[
-
1
]
except
subprocess
.
SubprocessError
:
nvcc
=
"Not Available"
return
nvcc
def
_get_gpu_info
():
gpu_info
=
subprocess
.
check_output
([
'nvidia-smi'
,
'-L'
]).
decode
().
strip
()
gpu_info
=
gpu_info
.
split
(
'
\n
'
)
for
i
in
range
(
len
(
gpu_info
)):
gpu_info
[
i
]
=
' '
.
join
(
gpu_info
[
i
].
split
(
' '
)[:
4
])
return
gpu_info
def
get_environ_info
():
"""collect environment information"""
env_info
=
{}
env_info
[
'system platform'
]
=
sys
.
platform
if
env_info
[
'system platform'
]
==
'linux'
:
lsb_v
=
subprocess
.
check_output
([
'lsb_release'
,
'-v'
]).
decode
().
strip
()
lsb_v
=
lsb_v
.
replace
(
'
\t
'
,
' '
)
lsb_d
=
subprocess
.
check_output
([
'lsb_release'
,
'-d'
]).
decode
().
strip
()
lsb_d
=
lsb_d
.
replace
(
'
\t
'
,
' '
)
env_info
[
'LSB'
]
=
[
lsb_v
,
lsb_d
]
env_info
[
'Python'
]
=
sys
.
version
.
replace
(
'
\n
'
,
''
)
compiled_with_cuda
=
paddle
.
fluid
.
is_compiled_with_cuda
()
env_info
[
'Paddle compiled with cuda'
]
=
compiled_with_cuda
if
compiled_with_cuda
:
cuda_home
=
_find_cuda_home
()
env_info
[
'cuda home'
]
=
cuda_home
env_info
[
'nvcc'
]
=
_get_nvcc_info
(
cuda_home
)
gpu_nums
=
fluid
.
core
.
get_cuda_device_count
()
env_info
[
'GPUs used'
]
=
gpu_nums
env_info
[
'CUDA_VISIBLE_DEVICES'
]
=
os
.
environ
.
get
(
'CUDA_VISIBLE_DEVICES'
)
env_info
[
'GPU'
]
=
_get_gpu_info
()
gcc
=
subprocess
.
check_output
([
'gcc'
,
'--version'
]).
decode
()
gcc
=
gcc
.
strip
().
split
(
'
\n
'
)[
0
]
env_info
[
'gcc'
]
=
gcc
env_info
[
'Paddle'
]
=
paddle
.
__version__
env_info
[
'OpenCV'
]
=
cv2
.
__version__
return
env_info
if
__name__
==
'__main__'
:
env_info
=
get_environ_info
()
for
k
,
v
in
env_info
.
items
():
print
(
'{}: {}'
.
format
(
k
,
v
))
dygraph/val.py
浏览文件 @
3a40055a
...
...
@@ -72,7 +72,7 @@ def parse_args():
def
main
(
args
):
env_info
=
get_environ_info
()
places
=
fluid
.
CUDAPlace
(
ParallelEnv
().
dev_id
)
\
if
env_info
[
'
place'
]
==
'cuda'
and
fluid
.
is_compiled_with_cuda
()
\
if
env_info
[
'
Paddle compiled with cuda'
]
and
env_info
[
'GPUs used'
]
\
else
fluid
.
CPUPlace
()
if
args
.
dataset
not
in
DATASETS
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录