提交 1b81a00e authored 作者: Frederic's avatar Frederic

Start a documentation section about memory/speed trade-off

上级 4e0b5023
......@@ -225,3 +225,42 @@ preferable not to use those dtypes together.
To help you find where float64 are created, see the
:attr:`warn_float64` Theano flag.
Theano memory/speed trade-off
-----------------------------
There is a few things you can easily do to change the trade-off
between speed and memory usage. It nothing is said, this affect the
CPU and GPU memory usage.
Could speed up and lower memory usage:
- :ref:`CuDNN <libdoc_cuda_dnn>` default CuDNN convolution use less
memory then Theano version. But some flags allow it to use more
memory. GPU only.
- Shortly avail, multi-GPU.
Could raise memory usage but speed up computation:
- :attr:`config.lib.cnmem` =1 # Do not raise much memory usage, but if you are at the limit of GPU memory available. GPU only.
- :attr:`config.allow_gc` =False
- :attr:`config.optimizer_excluding` =low_memory , GPU only for now.
Could lower the memory usage, but raise computation time:
- :attr:`config.scan.allow_gc` =True # Probably not significant slowdown if config.lib.cnmem is used.
- :attr:`config.scan.allow_output_prealloc` =False
- Use :func:`batch_normalization()
<theano.tensor.nnet.bn.batch_normalization>`. It use less memory
then building a corresponding Theano graph.
- Disable one or scan more optimizations:
- ``optimizer_excluding=scanOp_pushout_seqs_ops``
- ``optimizer_excluding=scan_pushout_dot1``
- ``optimizer_excluding=scanOp_pushout_output``
- Disable all optimization tagged as raising memory usage:
``optimizer_excluding=more_mem`` (currently only the 3 scan optimizations above)
- `float16 <https://github.com/Theano/Theano/issues/2908>`_.
If you want to analyze the memory usage during computation, the
simplest is to let the memory error happen during Theano execution and
use the Theano flags :attr:`exception_verbosity=high`.
......@@ -208,7 +208,7 @@ import theano and print the config variable, as in:
significant speed up on functions with many ops that are fast to
execute, but this increases Theano's memory usage.
.. attribute:: scan.allow_output_prealloc
.. attribute:: config.scan.allow_output_prealloc
Bool value, either ``True`` or ``False``
......@@ -219,6 +219,18 @@ import theano and print the config variable, as in:
give a significant speed up with Scan at the cost of slightly increased
memory usage.
.. attribute:: config.scan.allow_gc
Bool value, either ``True`` or ``False``
Default: ``False``
Allow/disallow gc inside of Scan.
If config.allow_gc is ``True``, but config.scan.allow_gc is
``False``, then we will gc the inner of scan after all
iterations. This is the default.
.. attribute:: openmp
Bool value: either True or False
......@@ -612,7 +624,7 @@ import theano and print the config variable, as in:
cost of precision. This also disables support for denormal
numbers.
.. attribute:: optimizer_excluding
.. attribute:: config.optimizer_excluding
Default: ""
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论