Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
e692e389
提交
e692e389
authored
12月 28, 2020
作者:
Michael Osthege
提交者:
Brandon T. Willard
1月 02, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove theano.compile.compilelock.set_lock_status
上级
ffbe1f76
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
30 行增加
和
54 行删除
+30
-54
pipeline.txt
doc/extending/pipeline.txt
+3
-7
compilelock.py
theano/compile/compilelock.py
+27
-47
没有找到文件。
doc/extending/pipeline.txt
浏览文件 @
e692e389
...
...
@@ -111,12 +111,9 @@ case if ``borrow`` was True, the thunk would be allowed to reuse (or
:attr:`config.blas__ldflags`, you will need to manually remove your compile cache,
using ``Theano/bin/theano-cache clear``
Theano also implements a lock mechanism that prevents
multiple compilations within the same compilation directory (to avoid
crashes with paralell execution of some scripts). This mechanism is
currently enabled by default, but if it causes any problem it may be
disabled using the function
``theano.compile.compilelock.set_lock_status(..)``.
Theano also implements a lock mechanism that prevents multiple compilations
within the same compilation directory (to avoid crashes with parallel
execution of some scripts).
Step 4 - Wrap the thunk in a pretty package
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
...
@@ -125,4 +122,3 @@ The thunk returned by the linker along with input and output
containers is unwieldy. ``function`` hides that complexity away so
that it can be used like a normal function with arguments and return
values.
theano/compile/compilelock.py
浏览文件 @
e692e389
...
...
@@ -20,7 +20,6 @@ __all__ = [
"lock"
,
"lock_ctx"
,
"release_lock"
,
"set_lock_status"
,
]
...
...
@@ -72,9 +71,6 @@ def _get_lock(lock_dir=None, **kw):
if
not
hasattr
(
get_lock
,
"n_lock"
):
# Initialization.
get_lock
.
n_lock
=
0
if
not
hasattr
(
get_lock
,
"lock_is_enabled"
):
# Enable lock by default.
get_lock
.
lock_is_enabled
=
True
get_lock
.
lock_dir
=
lock_dir
get_lock
.
unlocker
=
Unlocker
(
get_lock
.
lock_dir
)
else
:
...
...
@@ -86,33 +82,32 @@ def _get_lock(lock_dir=None, **kw):
get_lock
.
lock_dir
=
lock_dir
get_lock
.
unlocker
=
Unlocker
(
get_lock
.
lock_dir
)
if
get_lock
.
lock_is_enabled
:
# Only really try to acquire the lock if we do not have it already.
if
get_lock
.
n_lock
==
0
:
lock
(
get_lock
.
lock_dir
,
**
kw
)
atexit
.
register
(
Unlocker
.
unlock
,
get_lock
.
unlocker
)
# Store time at which the lock was set.
get_lock
.
start_time
=
time
.
time
()
else
:
# Check whether we need to 'refresh' the lock. We do this
# every 'config.compile__timeout / 2' seconds to ensure
# no one else tries to override our lock after their
# 'config.compile__timeout' timeout period.
if
get_lock
.
start_time
is
None
:
# This should not happen. So if this happen, clean up
# the lock state and raise an error.
while
get_lock
.
n_lock
>
0
:
release_lock
()
raise
Exception
(
"For some unknow reason, the lock was already "
"taken, but no start time was registered."
)
now
=
time
.
time
()
if
now
-
get_lock
.
start_time
>
config
.
compile__timeout
/
2
:
lockpath
=
os
.
path
.
join
(
get_lock
.
lock_dir
,
"lock"
)
_logger
.
info
(
f
"Refreshing lock {lockpath}"
)
refresh_lock
(
lockpath
)
get_lock
.
start_time
=
now
# Only really try to acquire the lock if we do not have it already.
if
get_lock
.
n_lock
==
0
:
lock
(
get_lock
.
lock_dir
,
**
kw
)
atexit
.
register
(
Unlocker
.
unlock
,
get_lock
.
unlocker
)
# Store time at which the lock was set.
get_lock
.
start_time
=
time
.
time
()
else
:
# Check whether we need to 'refresh' the lock. We do this
# every 'config.compile__timeout / 2' seconds to ensure
# no one else tries to override our lock after their
# 'config.compile__timeout' timeout period.
if
get_lock
.
start_time
is
None
:
# This should not happen. So if this happen, clean up
# the lock state and raise an error.
while
get_lock
.
n_lock
>
0
:
release_lock
()
raise
Exception
(
"For some unknow reason, the lock was already "
"taken, but no start time was registered."
)
now
=
time
.
time
()
if
now
-
get_lock
.
start_time
>
config
.
compile__timeout
/
2
:
lockpath
=
os
.
path
.
join
(
get_lock
.
lock_dir
,
"lock"
)
_logger
.
info
(
f
"Refreshing lock {lockpath}"
)
refresh_lock
(
lockpath
)
get_lock
.
start_time
=
now
get_lock
.
n_lock
+=
1
...
...
@@ -127,26 +122,11 @@ def release_lock():
get_lock
.
n_lock
-=
1
assert
get_lock
.
n_lock
>=
0
# Only really release lock once all lock requests have ended.
if
get_lock
.
lock_is_enabled
and
get_lock
.
n_lock
==
0
:
if
get_lock
.
n_lock
==
0
:
get_lock
.
start_time
=
None
get_lock
.
unlocker
.
unlock
(
force
=
False
)
def
set_lock_status
(
use_lock
):
"""
Enable or disable the lock on the compilation directory (which is enabled
by default). Disabling may make compilation slightly faster (but is not
recommended for parallel execution).
Parameters
----------
use_lock : bool
Whether to use the compilation lock or not.
"""
get_lock
.
lock_is_enabled
=
use_lock
# This is because None is a valid input for timeout
notset
=
object
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论