From 0a33808aec659a41d6128e43bede1f62b99a7f78 Mon Sep 17 00:00:00 2001 From: "lanbo.llb" Date: Thu, 3 Nov 2022 14:41:01 +0800 Subject: [PATCH 1/2] build with deeprec 2208 in cu114 --- scripts/python/common_setup.py | 5 +++-- scripts/python/tao_build.py | 4 ++++ .../mlir/xla/ral/context/stream_executor_based_impl.cc | 4 ++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/python/common_setup.py b/scripts/python/common_setup.py index 4eb779b7c89..59357e26666 100644 --- a/scripts/python/common_setup.py +++ b/scripts/python/common_setup.py @@ -374,7 +374,7 @@ def update_cpu_specific_setting(args): def get_tf_info(python_executable): output = subprocess.check_output( - '{} -c "import tensorflow as tf; print(tf.__version__); print(\'\\n\'.join(tf.sysconfig.get_compile_flags())); print(\'\\n\'.join(tf.sysconfig.get_link_flags()))"'.format( + '{} -c "import tensorflow as tf; print(tf.__version__); print(tf.__git_version__); print(\'\\n\'.join(tf.sysconfig.get_compile_flags())); print(\'\\n\'.join(tf.sysconfig.get_link_flags()))"'.format( python_executable ), shell=True, @@ -382,6 +382,7 @@ def get_tf_info(python_executable): lines = output.split("\n") major, minor, _ = lines[0].split(".") # lines[0] is version like 1.15.0 is_pai = "PAI" in lines[0] + is_deeprec = 'deeprec' in lines[1] header_dir, lib_dir, lib_name, cxx11_abi = '', '', '', '' for line in lines[1:]: if line.startswith("-I"): @@ -410,7 +411,7 @@ def get_tf_info(python_executable): raise Exception("Can not find tensorflow's built-in pb version!") else: raise Exception("Can not find {PB_HEADER_FILE} in tf's include dir!") - return major, minor, is_pai, header_dir, lib_dir, lib_name, cxx11_abi, tf_pb_version + return major, minor, is_pai, header_dir, lib_dir, lib_name, cxx11_abi, tf_pb_version, is_deeprec def deduce_cuda_info(): """Deduce cuda major and minor version and cuda directory.""" diff --git a/scripts/python/tao_build.py b/scripts/python/tao_build.py index 56d2f69c4be..43bf7c5fe00 100755 --- a/scripts/python/tao_build.py +++ b/scripts/python/tao_build.py @@ -201,9 +201,13 @@ def _write(line, cmd="build"): tf_lib_name, tf_cxx11_abi, tf_pb_version, + is_deeprec ) = get_tf_info(python_bin) _opt("cxxopt", f"-D_GLIBCXX_USE_CXX11_ABI={tf_cxx11_abi}") _opt("host_cxxopt", f"-D_GLIBCXX_USE_CXX11_ABI={tf_cxx11_abi}") + # quick solution, a little hacky + _opt("cxxopt", f"-DTF_IS_DEEPREC={is_deeprec}") + _opt("host_cxxopt", f"-DTF_IS_DEEPREC={is_deeprec}") _action_env("BLADE_WITH_TF", "1") _action_env("IF_CXX11_ABI", int(tf_cxx11_abi)) _action_env("TF_IS_PAI", int(is_pai)) diff --git a/tao_compiler/mlir/xla/ral/context/stream_executor_based_impl.cc b/tao_compiler/mlir/xla/ral/context/stream_executor_based_impl.cc index e0da6eaa348..102d9f40add 100644 --- a/tao_compiler/mlir/xla/ral/context/stream_executor_based_impl.cc +++ b/tao_compiler/mlir/xla/ral/context/stream_executor_based_impl.cc @@ -1392,6 +1392,9 @@ Status RunCudnnConvolution( se::DeviceMemoryBase& result_buffer, se::ScratchAllocator* scratch_allocator, se::Stream* stream, se::dnn::ProfileResult* profile_result) { +#if defined(TF_IS_DEEPREC) + return errors::Internal("Not supported for DeepREC yet"); +#else ConvolutionKind kind = params.kind; DeviceMemory input_buf(operand_buffers[0]); DeviceMemory filter_buf(operand_buffers[1]); @@ -1466,6 +1469,7 @@ Status RunCudnnConvolution( return errors::Internal("Unable to launch convolution"); } return Status::OK(); +#endif // TF_IS_DEEPREC } template From a6e2fcf19329732995b71683c30f5a78cc9c4382 Mon Sep 17 00:00:00 2001 From: "lanbo.llb" Date: Wed, 30 Nov 2022 14:11:11 +0000 Subject: [PATCH 2/2] fix ci failures --- scripts/python/tao_build.py | 1 - tensorflow_blade/build.py | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/python/tao_build.py b/scripts/python/tao_build.py index 43bf7c5fe00..1ad00311067 100755 --- a/scripts/python/tao_build.py +++ b/scripts/python/tao_build.py @@ -205,7 +205,6 @@ def _write(line, cmd="build"): ) = get_tf_info(python_bin) _opt("cxxopt", f"-D_GLIBCXX_USE_CXX11_ABI={tf_cxx11_abi}") _opt("host_cxxopt", f"-D_GLIBCXX_USE_CXX11_ABI={tf_cxx11_abi}") - # quick solution, a little hacky _opt("cxxopt", f"-DTF_IS_DEEPREC={is_deeprec}") _opt("host_cxxopt", f"-DTF_IS_DEEPREC={is_deeprec}") _action_env("BLADE_WITH_TF", "1") diff --git a/tensorflow_blade/build.py b/tensorflow_blade/build.py index 108883c14fd..90e78a92cd1 100755 --- a/tensorflow_blade/build.py +++ b/tensorflow_blade/build.py @@ -150,7 +150,10 @@ def _config(cfg_name, cmd="build"): tf_lib_name, tf_cxx11_abi, tf_pb_version, + is_deeprec ) = get_tf_info(which("python3")) + _opt("cxxopt", f"-DTF_IS_DEEPREC={is_deeprec}") + _opt("host_cxxopt", f"-DTF_IS_DEEPREC={is_deeprec}") _action_env("BLADE_WITH_TF", "1") _config("cxx11abi_" + tf_cxx11_abi) _action_env("IF_CXX11_ABI", int(tf_cxx11_abi)) @@ -260,7 +263,7 @@ def package(args): def test(args): execute("python3 setup.py cpp_test") device_mark = "not gpu_only" if args.device != "gpu" else "not cpu_only" - tf_major, _, _, _, _, _, _, _ = get_tf_info(which("python3")) + tf_major, _, _, _, _, _, _, _, _ = get_tf_info(which("python3")) tf_mark = "not tf1_only" if tf_major == "2" else "not tf2_only" execute(f"pytest tests/ -m '{device_mark} and {tf_mark}' -v --forked")