__init__.py 2.0 KB
Newer Older
Y
Yang Yu 已提交
1
from __future__ import print_function
2
# import all class inside framework into fluid module
Y
Update  
Yang Yu 已提交
3 4
import framework
from framework import *
Y
Yang Yu 已提交
5 6
# import all class inside executor into fluid module
import executor
Y
Update  
Yang Yu 已提交
7 8
from executor import *

Y
Yang Yu 已提交
9
import io
Y
Update  
Yang Yu 已提交
10 11
import evaluator
import initializer
12 13 14
import layers
import nets
import optimizer
Y
Update  
Yang Yu 已提交
15
import backward
16
import regularizer
Y
Update  
Yang Yu 已提交
17
from param_attr import ParamAttr
Y
Yu Yang 已提交
18
from data_feeder import DataFeeder
Y
Update  
Yang Yu 已提交
19
from core import LoDTensor, CPUPlace, CUDAPlace
T
done  
typhoonzero 已提交
20
from distribute_transpiler import DistributeTranspiler
Y
Update  
Yang Yu 已提交
21
import clip
22
from memory_optimization_transpiler import memory_optimize
23 24 25

Tensor = LoDTensor
__all__ = framework.__all__ + executor.__all__ + [
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
    'io',
    'initializer',
    'layers',
    'nets',
    'optimizer',
    'backward',
    'regularizer',
    'LoDTensor',
    'CPUPlace',
    'CUDAPlace',
    'Tensor',
    'ParamAttr'
    'DataFeeder',
    'clip',
    'DistributeTranspiler',
    'memory_optimize',
42 43 44
]


Y
Yang Yu 已提交
45
def __bootstrap__():
46 47
    """
    Enable reading gflags from environment variables.
Y
Yu Yang 已提交
48

49 50 51 52 53
    Returns:
        None
    """
    import sys
    import core
Y
Yang Yu 已提交
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
    import os

    try:
        num_threads = int(os.getenv('OMP_NUM_THREADS', '1'))
    except ValueError:
        num_threads = 1

    if num_threads > 1:
        print(
            'WARNING: OMP_NUM_THREADS set to {0}, not 1. The computation '
            'speed will not be optimized if you use data parallel. It will '
            'fail if this PaddlePaddle binary is compiled with OpenBlas since'
            ' OpenBlas does not support multi-threads.'.format(num_threads),
            file=sys.stderr)
        print('PLEASE USE OMP_NUM_THREADS WISELY.', file=sys.stderr)

    os.environ['OMP_NUM_THREADS'] = str(num_threads)

Y
Yang Yu 已提交
72
    read_env_flags = ['use_pinned_memory', 'check_nan_inf']
73
    if core.is_compile_gpu():
D
dzhwinter 已提交
74
        read_env_flags += ['fraction_of_gpu_memory_to_use', 'op_sync']
Q
QI JUN 已提交
75 76
    core.init_gflags([sys.argv[0]] +
                     ["--tryfromenv=" + ",".join(read_env_flags)])
Y
Yang Yu 已提交
77
    core.init_glog(sys.argv[0])
78
    core.init_devices()
D
dzhwinter 已提交
79

80

Y
Yang Yu 已提交
81
__bootstrap__()