Apollo 11.0
自动驾驶开放平台
gpu_resource_statistic.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2023 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#pragma once
18
19#ifdef __x86_64__
20#include <nvml.h>
21#endif
22
23#ifdef __aarch64__
24#include <regex>
25#endif
26
27#include "modules/statistics_msgs/resource_statistic.pb.h"
28
29#include "cyber/cyber.h"
34namespace apollo {
35namespace resource_statistic {
36
38public:
44 bool GetGpuMetric(GpuMetric* gpu_metric);
45
46private:
51 bool Init();
52
53#ifdef __x86_64__
59 bool GetGpuNumber(unsigned int* deviceCount);
60
67 bool GetGpuDeviceHandle(const unsigned int index, nvmlDevice_t* device);
68
75 bool GetGpuName(const nvmlDevice_t& device, char* name);
76
83 bool GetUsage(const nvmlDevice_t& device, float* usage);
84
91 bool GetTemperature(const nvmlDevice_t& device, float* temp);
92#endif
93};
94
95} // namespace resource_statistic
96} // namespace apollo
bool GetGpuMetric(GpuMetric *gpu_metric)
Get GPU metric and write it into gpu_metric.
first check imutoantoffset saved in device
Definition readme.txt:2
class register implement
Definition arena_queue.h:37