__init__.py 1.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
# import all class inside framework into fluid module
import framework
from framework import *
# import all class inside executor into fluid module
import executor
from executor import *

import io
import evaluator
import initializer
import layers
import nets
import optimizer
import backward
import regularizer
Y
Yu Yang 已提交
16
from param_attr import ParamAttr
Y
Yu Yang 已提交
17
from data_feeder import DataFeeder
D
dzhwinter 已提交
18
from core import LoDTensor, CPUPlace, CUDAPlace
T
done  
typhoonzero 已提交
19
from distribute_transpiler import DistributeTranspiler
Y
Yu Yang 已提交
20
import clip
21 22 23 24

Tensor = LoDTensor
__all__ = framework.__all__ + executor.__all__ + [
    'io', 'initializer', 'layers', 'nets', 'optimizer', 'backward',
D
dzhwinter 已提交
25
    'regularizer', 'LoDTensor', 'CPUPlace', 'CUDAPlace', 'Tensor', 'ParamAttr'
26
    'DataFeeder', 'clip', 'DistributeTranspiler'
27 28 29 30 31 32
]


def __read_gflags_from_env__():
    """
    Enable reading gflags from environment variables.
Y
Yu Yang 已提交
33

34 35 36 37 38 39 40 41
    Returns:
        None
    """
    import sys
    import core
    read_env_flags = ['use_pinned_memory']
    if core.is_compile_gpu():
        read_env_flags.append('fraction_of_gpu_memory_to_use')
Q
QI JUN 已提交
42 43
    core.init_gflags([sys.argv[0]] +
                     ["--tryfromenv=" + ",".join(read_env_flags)])
44

D
dzhwinter 已提交
45 46 47 48 49
    if core.is_compile_gpu():
        core.init_devices(["CPU", "GPU:0"])
    else:
        core.init_devices(["CPU"])

50 51

__read_gflags_from_env__()