提交 8b62d9e4 authored 作者: James Bergstra's avatar James Bergstra

THEANORC supports multiple ":"-delimited theanorc files

上级 aa839c64
...@@ -54,8 +54,8 @@ Environment Variables ...@@ -54,8 +54,8 @@ Environment Variables
.. envvar:: THEANORC .. envvar:: THEANORC
This is the location of the .theanorc file which is in ConfigParser The location[s] of the .theanorc file[s] in ConfigParser format.
format. It defaults to ``$HOME/.theanorc``. It defaults to ``$HOME/.theanorc``.
Here is the .theanorc equivalent to the THEANO_FLAGS in the example above: Here is the .theanorc equivalent to the THEANO_FLAGS in the example above:
...@@ -68,6 +68,13 @@ Environment Variables ...@@ -68,6 +68,13 @@ Environment Variables
[nvcc] [nvcc]
fastmath = True fastmath = True
Multiple configuration files can be specified by separating them with ':'
characters (as in $PATH). Multiple configuration files will be merged,
with earlier (left-most) files taking priority over later files in the
case that multiple files specify values for a common configuration option.
For example, to override system-wide settings with personal ones,
set ``THEANORC=~/.theanorc:/etc/theanorc``
The rest of this page describes some of the more common and important flags The rest of this page describes some of the more common and important flags
that you might want to use. For the complete list (including documentation), that you might want to use. For the complete list (including documentation),
import theano and print the config variable, as in: import theano and print the config variable, as in:
......
...@@ -14,9 +14,14 @@ THEANO_FLAGS=os.getenv("THEANO_FLAGS","") ...@@ -14,9 +14,14 @@ THEANO_FLAGS=os.getenv("THEANO_FLAGS","")
# [section.]option[=value] entries. If the section part is omited, their should be only one # [section.]option[=value] entries. If the section part is omited, their should be only one
# section with that contain the gived option. # section with that contain the gived option.
theano_cfg_path = os.getenv('THEANORC', '~/.theanorc') # THEANORC=~/.theanorc:~lisa/.theanorc
def config_files_from_theanorc():
rval = [os.path.expanduser(s) for s in os.getenv('THEANORC', '~/.theanorc').split(':')]
rval.reverse()
print "THEANORC", rval
return rval
theano_cfg = ConfigParser.SafeConfigParser() theano_cfg = ConfigParser.SafeConfigParser()
theano_cfg.read([os.path.expanduser(theano_cfg_path)]) theano_cfg.read(config_files_from_theanorc())
def parse_env_flags(flags, name , default_value=None): def parse_env_flags(flags, name , default_value=None):
#The value in the env variable THEANO_FLAGS override the previous value #The value in the env variable THEANO_FLAGS override the previous value
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论