Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
b337a5c1
提交
b337a5c1
authored
3月 07, 2013
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add new commands to theano-cache.
"theano-cache basecompiledir purge" is useful when the kernel or Python version changes, as cache directories accumulate.
上级
816a83e3
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
98 行增加
和
28 行删除
+98
-28
theano-cache
bin/theano-cache
+64
-28
compiledir.py
theano/gof/compiledir.py
+34
-0
没有找到文件。
bin/theano-cache
浏览文件 @
b337a5c1
...
@@ -10,36 +10,72 @@ from theano.gof.cc import get_module_cache
...
@@ -10,36 +10,72 @@ from theano.gof.cc import get_module_cache
_logger
=
logging
.
getLogger
(
'theano.bin.theano-cache'
)
_logger
=
logging
.
getLogger
(
'theano.bin.theano-cache'
)
_logger
.
setLevel
(
logging
.
WARN
)
_logger
.
setLevel
(
logging
.
WARN
)
if
len
(
sys
.
argv
)
==
1
:
print
config
.
compiledir
def
print_help
(
exit_status
):
elif
sys
.
argv
[
1
]
==
'clear'
:
if
exit_status
:
# We skip the refresh on module cache creation because the refresh will
print
'command "
%
s" not recognized'
%
(
' '
.
join
(
sys
.
argv
))
# be done when calling clear afterwards.
cache
=
get_module_cache
(
init_args
=
dict
(
do_refresh
=
False
))
cache
.
clear
(
unversioned_min_age
=-
1
,
clear_base_files
=
True
,
delete_if_problem
=
True
)
# Print a warning if some cached modules were not removed, so that the user
# knows he should manually delete them to properly clear the cache.
items
=
[
item
for
item
in
sorted
(
os
.
listdir
(
cache
.
dirname
))
if
item
.
startswith
(
'tmp'
)]
if
items
:
_logger
.
warning
(
'There remain elements in the cache dir that you may '
'need to erase manually. The cache dir is:
\n
%
s'
%
config
.
compiledir
)
_logger
.
debug
(
'Remaining elements (
%
s):
%
s'
%
(
len
(
items
),
', '
.
join
(
items
)))
elif
sys
.
argv
[
1
]
==
'list'
:
theano
.
gof
.
compiledir
.
print_compiledir_content
()
elif
sys
.
argv
[
1
]
==
'cleanup'
:
theano
.
gof
.
compiledir
.
cleanup
()
elif
sys
.
argv
[
1
]
==
'unlock'
:
theano
.
gof
.
compilelock
.
force_unlock
()
print
'Lock successfully removed!'
else
:
print
'command "
%
s" not recognized'
%
sys
.
argv
[
1
]
print
'Type "theano-cache" to print the cache location'
print
'Type "theano-cache" to print the cache location'
print
'Type "theano-cache help" to print this help'
print
'Type "theano-cache clear" to erase the cache'
print
'Type "theano-cache clear" to erase the cache'
print
'Type "theano-cache list" to print the cache content'
print
'Type "theano-cache list" to print the cache content'
print
'Type "theano-cache unlock" to unlock the cache directory'
print
'Type "theano-cache unlock" to unlock the cache directory'
print
'Type "theano-cache cleanup" to delete keys in the old format'
print
'Type "theano-cache cleanup" to delete keys in the old format'
sys
.
exit
(
1
)
print
'Type "theano-cache purge" to force deletion of the cache directory'
print
(
'Type "theano-cache basecompiledir" '
'to print the parent of the cache directory'
)
print
(
'Type "theano-cache basecompiledir list" '
'to print the content of the base compile dir'
)
print
(
'Type "theano-cache basecompiledir purge" '
'to remove everything in the base compile dir, '
'that is, erase ALL cache directories'
)
sys
.
exit
(
exit_status
)
if
len
(
sys
.
argv
)
==
1
:
print
config
.
compiledir
elif
len
(
sys
.
argv
)
==
2
:
if
sys
.
argv
[
1
]
==
'help'
:
print_help
(
exit_status
=
0
)
if
sys
.
argv
[
1
]
==
'clear'
:
# We skip the refresh on module cache creation because the refresh will
# be done when calling clear afterwards.
cache
=
get_module_cache
(
init_args
=
dict
(
do_refresh
=
False
))
cache
.
clear
(
unversioned_min_age
=-
1
,
clear_base_files
=
True
,
delete_if_problem
=
True
)
# Print a warning if some cached modules were not removed, so that the
# user knows he should manually delete them, or call
# theano-cache purge, # to properly clear the cache.
items
=
[
item
for
item
in
sorted
(
os
.
listdir
(
cache
.
dirname
))
if
item
.
startswith
(
'tmp'
)]
if
items
:
_logger
.
warning
(
'There remain elements in the cache dir that you may '
'need to erase manually. The cache dir is:
\n
%
s
\n
'
'You can also call "theano-cache purge" to '
'remove everything from that directory.'
%
config
.
compiledir
)
_logger
.
debug
(
'Remaining elements (
%
s):
%
s'
%
(
len
(
items
),
', '
.
join
(
items
)))
elif
sys
.
argv
[
1
]
==
'list'
:
theano
.
gof
.
compiledir
.
print_compiledir_content
()
elif
sys
.
argv
[
1
]
==
'cleanup'
:
theano
.
gof
.
compiledir
.
cleanup
()
elif
sys
.
argv
[
1
]
==
'unlock'
:
theano
.
gof
.
compilelock
.
force_unlock
()
print
'Lock successfully removed!'
elif
sys
.
argv
[
1
]
==
'purge'
:
theano
.
gof
.
compiledir
.
compiledir_purge
()
elif
sys
.
argv
[
1
]
==
'basecompiledir'
:
# Simply print the base_compiledir
print
theano
.
config
.
base_compiledir
else
:
print_help
(
exit_status
=
1
)
elif
len
(
sys
.
argv
)
==
3
and
sys
.
argv
[
1
]
==
'basecompiledir'
:
if
sys
.
argv
[
2
]
==
'list'
:
theano
.
gof
.
compiledir
.
basecompiledir_ls
()
elif
sys
.
argv
[
2
]
==
'purge'
:
theano
.
gof
.
compiledir
.
basecompiledir_purge
()
else
:
print_help
(
exit_status
=
1
)
else
:
print_help
(
exit_status
=
1
)
theano/gof/compiledir.py
浏览文件 @
b337a5c1
...
@@ -301,3 +301,37 @@ def print_compiledir_content():
...
@@ -301,3 +301,37 @@ def print_compiledir_content():
" 1 op (was compiled with the C linker)"
%
more_than_one_ops
)
" 1 op (was compiled with the C linker)"
%
more_than_one_ops
)
print
(
"Skipped
%
d files that contained 0 op "
print
(
"Skipped
%
d files that contained 0 op "
"(are they always theano.scalar ops?)"
%
zeros_op
)
"(are they always theano.scalar ops?)"
%
zeros_op
)
def
compiledir_purge
():
shutil
.
rmtree
(
config
.
compiledir
)
def
basecompiledir_ls
():
subdirs
=
[]
others
=
[]
for
f
in
os
.
listdir
(
config
.
base_compiledir
):
if
os
.
path
.
isdir
(
os
.
path
.
join
(
config
.
base_compiledir
,
f
)):
subdirs
.
append
(
f
)
else
:
others
.
append
(
f
)
subdirs
=
sorted
(
subdirs
)
others
=
sorted
(
others
)
print
'Base compile dir is
%
s'
%
theano
.
config
.
base_compiledir
print
'Sub-directories (possible compile caches):'
for
d
in
subdirs
:
print
'
%
s'
%
d
if
not
subdirs
:
print
' (None)'
if
others
:
print
print
'Other files in base_compiledir:'
for
f
in
others
:
print
'
%
s'
%
f
def
basecompiledir_purge
():
shutil
.
rmtree
(
config
.
base_compiledir
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论