Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
e7c3d879
提交
e7c3d879
authored
2月 07, 2012
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add theano-cache cleanup that delete the old keys with ndarray from the cache.
上级
124829f7
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
53 行增加
和
9 行删除
+53
-9
theano-cache
bin/theano-cache
+3
-0
compiledir.py
theano/gof/compiledir.py
+50
-9
没有找到文件。
bin/theano-cache
浏览文件 @
e7c3d879
...
...
@@ -28,6 +28,8 @@ elif sys.argv[1] in ('clear'):
(
len
(
items
),
', '
.
join
(
items
)))
elif
sys
.
argv
[
1
]
in
(
'list'
):
theano
.
gof
.
compiledir
.
print_compiledir_content
()
elif
sys
.
argv
[
1
]
in
(
'cleanup'
):
theano
.
gof
.
compiledir
.
cleanup
()
elif
sys
.
argv
[
1
]
==
'unlock'
:
theano
.
gof
.
compilelock
.
force_unlock
()
print
'Lock successfully removed!'
...
...
@@ -37,5 +39,6 @@ else:
print
'Type "theano-cache clear" to erase the cache'
print
'Type "theano-cache list" to print the cache content'
print
'Type "theano-cache unlock" to unlock the cache directory'
print
'Type "theano-cache cleanup" to delete old key format'
sys
.
exit
(
1
)
theano/gof/compiledir.py
浏览文件 @
e7c3d879
...
...
@@ -3,9 +3,12 @@ import errno
import
os
import
platform
import
re
import
shutil
import
sys
import
textwrap
import
numpy
import
theano
from
theano.configparser
import
config
,
AddConfigVar
,
ConfigParam
,
StrParam
...
...
@@ -106,18 +109,56 @@ AddConfigVar('compiledir',
allow_override
=
False
))
def
flatten
(
a
):
if
isinstance
(
a
,
(
tuple
,
list
,
set
)):
l
=
[]
for
item
in
a
:
l
.
extend
(
flatten
(
item
))
return
l
else
:
return
[
a
]
def
cleanup
():
""" Delete old keys from the compiledir
We define old key as key that have an ndarray in them.
Now we use an hash in the keys of the constant data.
If there is no key left for a compiled module, we delete the module.
"""
compiledir
=
theano
.
config
.
compiledir
for
directory
in
os
.
listdir
(
compiledir
):
file
=
None
try
:
try
:
filename
=
os
.
path
.
join
(
compiledir
,
directory
,
"key.pkl"
)
file
=
open
(
filename
,
'rb'
)
#print file
try
:
keydata
=
cPickle
.
load
(
file
)
for
key
in
list
(
keydata
.
keys
):
for
obj
in
flatten
(
key
):
if
isinstance
(
obj
,
numpy
.
ndarray
):
keydata
.
remove_key
(
key
)
break
if
len
(
keydata
.
keys
)
==
0
:
shutil
.
rmtree
(
os
.
path
.
join
(
compiledir
,
directory
))
pass
except
EOFError
:
print
(
"ERROR while reading this key file '
%
s'."
" Delete its directory"
%
filename
)
except
IOError
:
pass
finally
:
if
file
is
not
None
:
file
.
close
()
def
print_compiledir_content
():
max_key_file_size
=
1
*
1024
*
1024
# 1M
def
flatten
(
a
):
if
isinstance
(
a
,
(
tuple
,
list
,
set
)):
l
=
[]
for
item
in
a
:
l
.
extend
(
flatten
(
item
))
return
l
else
:
return
[
a
]
compiledir
=
theano
.
config
.
compiledir
table
=
[]
more_than_one_ops
=
0
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论