Skip to content

Commit

Permalink
Merge pull request PaddlePaddle#13 from lxsbupt/gpugraph
Browse files Browse the repository at this point in the history
Add gpu_graph_utils.h
  • Loading branch information
lxsbupt authored May 31, 2022
2 parents 2a16ca7 + 8253f4e commit f24c3e9
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions paddle/fluid/framework/fleet/heter_ps/gpu_graph_utils.h
Original file line number Diff line number Diff line change
@@ -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 <stdio.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#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

0 comments on commit f24c3e9

Please sign in to comment.