__init__.py 2.1 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
T
typhoonzero 已提交
21
from distribute_transpiler_simple import SimpleDistributeTranspiler
Y
Update  
Yang Yu 已提交
22
import clip
23
from memory_optimization_transpiler import memory_optimize
24 25 26 27

Tensor = LoDTensor
__all__ = framework.__all__ + executor.__all__ + [
    'io', 'initializer', 'layers', 'nets', 'optimizer', 'backward',
28 29 30
    'regularizer', 'LoDTensor', 'CPUPlace', 'CUDAPlace', 'Tensor', 'ParamAttr',
    'DataFeeder', 'clip', 'SimpleDistributeTranspiler', 'DistributeTranspiler',
    'memory_optimize'
31 32 33
]


Y
Yang Yu 已提交
34
def __bootstrap__():
35 36
    """
    Enable reading gflags from environment variables.
Y
Yu Yang 已提交
37

38 39 40 41 42
    Returns:
        None
    """
    import sys
    import core
Y
Yang Yu 已提交
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
    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 已提交
61
    read_env_flags = ['use_pinned_memory', 'check_nan_inf']
62
    if core.is_compile_gpu():
D
dzhwinter 已提交
63
        read_env_flags += ['fraction_of_gpu_memory_to_use', 'op_sync']
Q
QI JUN 已提交
64 65
    core.init_gflags([sys.argv[0]] +
                     ["--tryfromenv=" + ",".join(read_env_flags)])
Y
Yang Yu 已提交
66
    core.init_glog(sys.argv[0])
67
    core.init_devices()
D
dzhwinter 已提交
68

69

Y
Yang Yu 已提交
70
__bootstrap__()