Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PARL
提交
af882e17
P
PARL
项目概览
PaddlePaddle
/
PARL
通知
67
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
3
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PARL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
3
合并请求
3
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
af882e17
编写于
8月 19, 2020
作者:
T
TomorrowIsAnOtherDay
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
first commit
上级
0ebb57de
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
71 addition
and
8 deletion
+71
-8
parl/remote/job.py
parl/remote/job.py
+4
-6
parl/remote/tests/cluster_test.py
parl/remote/tests/cluster_test.py
+0
-1
parl/remote/tests/paddle_gpu_test.py
parl/remote/tests/paddle_gpu_test.py
+63
-0
parl/remote/utils.py
parl/remote/utils.py
+4
-1
未找到文件。
parl/remote/job.py
浏览文件 @
af882e17
...
...
@@ -66,21 +66,19 @@ class Job(object):
self
.
log_server_address
=
log_server_address
self
.
job_ip
=
get_ip_address
()
self
.
pid
=
os
.
getpid
()
self
.
run_job_process
=
Process
(
target
=
self
.
run
,
args
=
(
job_address_sender
,
job_id_sender
))
self
.
run_job_process
.
start
()
"""
NOTE:
In Windows, it will raise errors when creating threading.Lock before starting multiprocess.Process.
"""
self
.
lock
=
threading
.
Lock
()
self
.
_create_sockets
()
th
=
threading
.
Thread
(
target
=
self
.
_create_sockets
)
th
.
setDaemon
(
True
)
th
.
start
()
process
=
psutil
.
Process
(
self
.
pid
)
self
.
init_memory
=
float
(
process
.
memory_info
()[
0
])
/
(
1024
**
2
)
self
.
run
_job_process
.
join
(
)
self
.
run
(
job_address_sender
,
job_id_sender
)
with
self
.
lock
:
self
.
kill_job_socket
.
send_multipart
(
...
...
parl/remote/tests/cluster_test.py
浏览文件 @
af882e17
...
...
@@ -13,7 +13,6 @@
# limitations under the License.
import
unittest
import
parl
from
parl.remote.master
import
Master
from
parl.remote.worker
import
Worker
...
...
parl/remote/tests/paddle_gpu_test.py
0 → 100644
浏览文件 @
af882e17
# Copyright (c) 2021 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
unittest
import
parl
from
parl.remote.master
import
Master
from
parl.remote.worker
import
Worker
import
time
import
threading
from
parl.remote.client
import
disconnect
from
parl.remote
import
exceptions
import
subprocess
from
parl.utils
import
logger
import
paddle.fluid
as
fluid
import
os
@
parl
.
remote_class
class
Actor
(
object
):
def
__init__
(
self
):
os
.
environ
[
'CUDA_VISIBLE_DEVICES'
]
=
"0"
if
parl
.
utils
.
is_gpu_available
():
place
=
fluid
.
CUDAPlace
(
0
)
else
:
place
=
fluid
.
CPUPlace
()
exe
=
fluid
.
Executor
(
place
)
exe
.
run
(
fluid
.
default_startup_program
())
class
TestCluster
(
unittest
.
TestCase
):
def
tearDown
(
self
):
disconnect
()
def
test_gpu
(
self
):
master
=
Master
(
port
=
8241
)
th
=
threading
.
Thread
(
target
=
master
.
run
)
th
.
start
()
time
.
sleep
(
1
)
worker1
=
Worker
(
'localhost:8241'
,
4
)
parl
.
connect
(
'localhost:8241'
)
actor
=
Actor
()
del
actor
master
.
exit
()
worker1
.
exit
()
if
__name__
==
'__main__'
:
unittest
.
main
()
parl/remote/utils.py
浏览文件 @
af882e17
...
...
@@ -114,7 +114,7 @@ def locate_remote_file(module_path):
module_path: Absolute path of the module.
Example:
module_path: /home/user/dir/subdir/my_module
module_path: /home/user/dir/subdir/my_module
(or) ./dir/main
entry_file: /home/user/dir/main.py
--------> relative_path: subdir/my_module
"""
...
...
@@ -129,6 +129,9 @@ def locate_remote_file(module_path):
if
os
.
path
.
isfile
(
to_check_path
):
entry_path
=
path
break
# transfer the relative path to the absolute path
if
not
os
.
path
.
isabs
(
module_path
):
module_path
=
os
.
path
.
abspath
(
module_path
)
if
entry_path
is
None
or
\
(
module_path
.
startswith
(
os
.
sep
)
and
entry_path
!=
module_path
[:
len
(
entry_path
)]):
raise
FileNotFoundError
(
"cannot locate the remote file"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录