Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
f8241bfb
Unverified
Commit
f8241bfb
authored
Jul 06, 2024
by
Jeffrey Morgan
Committed by
GitHub
Jul 06, 2024
Browse files
gpu: report system free memory instead of 0 (#5521)
parent
4607c706
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
3 deletions
+26
-3
gpu/gpu_darwin.go
gpu/gpu_darwin.go
+1
-1
gpu/gpu_info_darwin.h
gpu/gpu_info_darwin.h
+1
-0
gpu/gpu_info_darwin.m
gpu/gpu_info_darwin.m
+24
-2
No files found.
gpu/gpu_darwin.go
View file @
f8241bfb
...
...
@@ -56,7 +56,7 @@ func GetCPUInfo() GpuInfoList {
func
GetCPUMem
()
(
memInfo
,
error
)
{
return
memInfo
{
TotalMemory
:
uint64
(
C
.
getPhysicalMemory
()),
FreeMemory
:
0
,
FreeMemory
:
uint64
(
C
.
getFreeMemory
())
,
},
nil
}
...
...
gpu/gpu_info_darwin.h
View file @
f8241bfb
...
...
@@ -2,3 +2,4 @@
#include <stdint.h>
uint64_t
getRecommendedMaxVRAM
();
uint64_t
getPhysicalMemory
();
uint64_t
getFreeMemory
();
gpu/gpu_info_darwin.m
View file @
f8241bfb
// go:build darwin
#import
<Foundation
/
Foundation.h
>
#import
<mach
/
mach.h
>
#include "gpu_info_darwin.h"
uint64_t getRecommendedMaxVRAM() {
...
...
@@ -8,6 +9,27 @@ uint64_t getRecommendedMaxVRAM() {
return result;
}
// getPhysicalMemory returns the total physical memory in bytes
uint64_t getPhysicalMemory() {
return [[NSProcessInfo processInfo] physicalMemory];
return [NSProcessInfo processInfo].physicalMemory;
}
// getFreeMemory returns the total free memory in bytes, including inactive
// memory that can be reclaimed by the system.
uint64_t getFreeMemory() {
mach_port_t host_port = mach_host_self();
mach_msg_type_number_t host_size = sizeof(vm_statistics64_data_t) / sizeof(integer_t);
vm_size_t pagesize;
vm_statistics64_data_t vm_stat;
host_page_size(host_port,
&pagesize);
if (host_statistics64(host_port, HOST_VM_INFO64, (host_info64_t)
&
vm_stat,
&
host_size) != KERN_SUCCESS) {
return 0;
}
uint64_t free_memory = (uint64_t)vm_stat.free_count * pagesize;
free_memory += (uint64_t)vm_stat.speculative_count * pagesize;
free_memory += (uint64_t)vm_stat.inactive_count * pagesize;
return free_memory;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment