From 9cb799be504529efaf7e6eed8fd6d6b191e20778 Mon Sep 17 00:00:00 2001 From: Jiabin Yang Date: Tue, 25 Jun 2019 15:20:45 +0800 Subject: [PATCH] test=develop, Revert "Add multi gpu install check" (#18313) * Revert "Add multi gpu install check (#18229)" This reverts commit 61ed06b29a976d94c03386de37bd79cba042878a. * test=develop, start ci --- python/paddle/fluid/install_check.py | 61 +++++++--------------------- 1 file changed, 15 insertions(+), 46 deletions(-) diff --git a/python/paddle/fluid/install_check.py b/python/paddle/fluid/install_check.py index 4f2cd2f0d8..527ae3a914 100644 --- a/python/paddle/fluid/install_check.py +++ b/python/paddle/fluid/install_check.py @@ -12,40 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os -from . import core - - -def process_env(): - env = os.environ - device_list = [] - if env.get('CUDA_VISIBLE_DEVICES') is not None: - cuda_devices = env['CUDA_VISIBLE_DEVICES'] - if cuda_devices == "" or len(cuda_devices) == 0: - os.environ['CUDA_VISIBLE_DEVICES'] = "0,1" - device_list = [0, 1] - elif len(cuda_devices) == 1: - device_list.append(0) - elif len(cuda_devices) > 1: - for i in range(len(cuda_devices.split(","))): - device_list.append(i) - return device_list - else: - if core.get_cuda_device_count() > 1: - os.environ['CUDA_VISIBLE_DEVICES'] = "0,1" - return [0, 1] - else: - os.environ['CUDA_VISIBLE_DEVICES'] = "0" - return [0] - - -device_list = [] -if core.is_compiled_with_cuda(): - device_list = process_env() -else: - device_list = [0, 1] # for CPU 0,1 - -from .framework import Program, program_guard, unique_name +from .framework import Program, program_guard, unique_name, default_startup_program from .param_attr import ParamAttr from .initializer import Constant from . import layers @@ -57,6 +24,7 @@ from . import core from . import compiler import logging import numpy as np +import os __all__ = ['run_check'] @@ -83,12 +51,13 @@ def run_check(): use_cuda = False if not core.is_compiled_with_cuda() else True place = core.CPUPlace() if not core.is_compiled_with_cuda( ) else core.CUDAPlace(0) - np_inp_single = np.array([[1.0, 2.0], [3.0, 4.0]], dtype=np.float32) - inp = [] - for i in range(len(device_list)): - inp.append(np_inp_single) - np_inp_muti = np.array(inp) - np_inp_muti = np_inp_muti.reshape(len(device_list), 2, 2) + np_inp = np.array([[1.0, 2.0], [3.0, 4.0]], dtype=np.float32) + + if use_cuda: + if core.get_cuda_device_count() > 1: + os.environ['CUDA_VISIBLE_DEVICES'] = "0,1" + else: + os.environ['CUDA_VISIBLE_DEVICES'] = "0" def test_parallerl_exe(): train_prog = Program() @@ -103,13 +72,13 @@ def run_check(): build_strategy = compiler.BuildStrategy() build_strategy.enable_inplace = True build_strategy.memory_optimize = True - inp = layers.data(name="inp", shape=[2, 2]) + inp = layers.data( + name="inp", shape=[2, 2], append_batch_size=False) simple_layer = SimpleLayer("simple_layer") out = simple_layer(inp) exe = executor.Executor(place) if use_cuda: - for i in device_list: - places.append(core.CUDAPlace(i)) + places = [core.CUDAPlace(0), core.CUDAPlace(1)] else: places = [core.CPUPlace(), core.CPUPlace()] loss = layers.mean(out) @@ -124,7 +93,7 @@ def run_check(): exe.run(startup_prog) exe.run(compiled_prog, - feed={inp.name: np_inp_muti}, + feed={inp.name: np_inp}, fetch_list=[loss.name]) def test_simple_exe(): @@ -146,7 +115,7 @@ def run_check(): if not core.is_compiled_with_cuda() else core.CUDAPlace(0)) exe0.run(startup_prog) - exe0.run(feed={inp0.name: np_inp_single}, + exe0.run(feed={inp0.name: np_inp}, fetch_list=[out0.name, param_grads[1].name]) test_simple_exe() @@ -170,4 +139,4 @@ def run_check(): print("\n Original Error is: {}".format(e)) print( "Your Paddle Fluid is installed successfully ONLY for SINGLE GPU or CPU! " - "\n Let's start deep Learning with Paddle Fluid now") + "\n Let's start deep Learning with Paddle Fluid now!") -- GitLab