Ai
2 Star 2 Fork 2

DeepSpark/go-ixml

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.go 1.81 KB
一键复制 编辑 原始数据 按行查看 历史
/*
Copyright (c) 2024, Shanghai Iluvatar CoreX Semiconductor Co., Ltd.
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.
*/
package main
import (
"fmt"
"log"
"gitee.com/deep-spark/go-ixml/pkg/ixml"
)
func main() {
ret := ixml.AbsInit("/usr/local/corex/lib/libixml.so")
if ret != ixml.SUCCESS {
log.Fatalf("Unable to initialize IXML: %v", ret)
}
defer func() {
ret := ixml.Shutdown()
if ret != ixml.SUCCESS {
log.Fatalf("Unable to shutdown IXML: %v", ret)
}
}()
count, ret := ixml.DeviceGetCount()
if ret != ixml.SUCCESS {
log.Fatalf("Unable to get device count %v", ret)
}
for i := uint(0); i < count; i++ {
var device ixml.Device
ret := ixml.DeviceGetHandleByIndex(i, &device)
if ret != ixml.SUCCESS {
fmt.Printf("Unable to get device at index %d: %v\n", i, ret)
continue
}
processInfos, ret := device.GetComputeRunningProcesses()
if ret != ixml.SUCCESS {
fmt.Printf("Unable to get processInfos %d: %v\n", i, ret)
continue
}
fmt.Printf("found processInfos %d on device %d\n", len(processInfos), i)
for _, processInfo := range processInfos {
fmt.Printf("processInfo.Pid: %d\n", processInfo.Pid)
fmt.Printf("processInfo.Name: %s\n", processInfo.Name)
fmt.Printf("processInfo.UsedGpuMemory: %d\n", processInfo.UsedGpuMemory)
}
}
fmt.Println("========================================")
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/deep-spark/go-ixml.git
git@gitee.com:deep-spark/go-ixml.git
deep-spark
go-ixml
go-ixml
a1a4e063554a

搜索帮助