From 8253f4ec1068dd70b6272d60cc5afa11c9ed6b6a Mon Sep 17 00:00:00 2001 From: lxsbupt Date: Tue, 31 May 2022 15:30:03 +0800 Subject: [PATCH] Add gpu_graph_utils.h --- .../fleet/heter_ps/gpu_graph_utils.h | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 paddle/fluid/framework/fleet/heter_ps/gpu_graph_utils.h diff --git a/paddle/fluid/framework/fleet/heter_ps/gpu_graph_utils.h b/paddle/fluid/framework/fleet/heter_ps/gpu_graph_utils.h new file mode 100644 index 00000000000000..9c9f7be8a310f7 --- /dev/null +++ b/paddle/fluid/framework/fleet/heter_ps/gpu_graph_utils.h @@ -0,0 +1,46 @@ +// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace paddle { +namespace framework { + +#include +#include +#include +#include +#include "paddle/fluid/platform/enforce.h" + +inline void debug_gpu_memory_info() { + int device_num = 0; + auto err = cudaGetDeviceCount(&device_num); + PADDLE_ENFORCE_EQ(err, cudaSuccess, + platform::errors::InvalidArgument("cudaGetDeviceCount failed!")); + + size_t avail{0}; + size_t total{0}; + for (int i = 0; i < device_num; ++i) { + cudaSetDevice(i); + auto err = cudaMemGetInfo(&avail, &total); + PADDLE_ENFORCE_EQ(err, cudaSuccess, + platform::errors::InvalidArgument("cudaMemGetInfo failed!")); + VLOG(0) << "update gpu memory!!! " + << "avail=" << avail << ", " + << "total=" << total << ", " + << "ratio=" << (total-avail)/double(total); + } +} + +}; // namespace framework +}; // namespace paddle +