-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
theano-cache
executable file
·44 lines (40 loc) · 1.79 KB
/
theano-cache
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python
import logging, os, sys
import theano
from theano import config
from theano.gof.cc import get_module_cache
_logger = logging.getLogger('theano.bin.theano-cache')
_logger.setLevel(logging.WARN)
if len(sys.argv) == 1:
print config.compiledir
elif sys.argv[1] in ('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 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] 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!'
else:
print 'command "%s" not recognized' % sys.argv[1]
print 'Type "theano-cache" to print the cache location'
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 keys in the old format'
sys.exit(1)