GPU-tunnistus valinnainen: cargo run --no-default-features toimii ilman nvml/wgpu
Native-node kääntyy nyt macOS:llä ja muilla koneilla ilman NVIDIA-ajureita: cargo run --no-default-features ← vain Ollama, ei GPU-tunnistusta cargo run ← oletus: GPU-tunnistus mukana (nvml + wgpu) Feature flag "gpu-detect" kontrolloi nvml-wrapper ja wgpu -riippuvuuksia. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -33,6 +33,7 @@ impl GpuInfo {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "gpu-detect")]
|
||||
/// Tunnistaa kaikki GPU:t wgpu:lla (NVIDIA/AMD/Apple/Intel)
|
||||
fn collect_gpus_wgpu() -> Vec<GpuInfo> {
|
||||
let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {
|
||||
@@ -84,6 +85,7 @@ fn collect_gpus_wgpu() -> Vec<GpuInfo> {
|
||||
gpus
|
||||
}
|
||||
|
||||
#[cfg(feature = "gpu-detect")]
|
||||
/// Täydentää NVIDIA-GPU:iden tiedot NVML:llä (VRAM, lämpötila, kuormitus)
|
||||
fn enrich_nvidia_gpus(gpus: &mut [GpuInfo]) {
|
||||
let Ok(nvml) = nvml_wrapper::Nvml::init() else { return };
|
||||
@@ -109,6 +111,7 @@ fn enrich_nvidia_gpus(gpus: &mut [GpuInfo]) {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "gpu-detect")]
|
||||
/// AMD GPU-tiedot Linuxin sysfs:stä (/sys/class/drm/)
|
||||
fn enrich_amd_gpus(gpus: &mut [GpuInfo]) {
|
||||
let Ok(entries) = std::fs::read_dir("/sys/class/drm") else { return };
|
||||
@@ -150,10 +153,12 @@ fn enrich_amd_gpus(gpus: &mut [GpuInfo]) {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "gpu-detect")]
|
||||
fn read_sysfs_u64(path: &std::path::Path) -> Option<u64> {
|
||||
std::fs::read_to_string(path).ok()?.trim().parse().ok()
|
||||
}
|
||||
|
||||
#[cfg(feature = "gpu-detect")]
|
||||
fn find_hwmon_temp(device_path: &std::path::Path) -> Option<u64> {
|
||||
let hwmon_dir = device_path.join("hwmon");
|
||||
let entries = std::fs::read_dir(&hwmon_dir).ok()?;
|
||||
@@ -166,8 +171,8 @@ fn find_hwmon_temp(device_path: &std::path::Path) -> Option<u64> {
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(feature = "gpu-detect")]
|
||||
/// Apple GPU-tiedot — wgpu/Metal antaa nimen, tarkempaa dataa ei saa ilman IOKit:ia
|
||||
/// mutta Metal adapter_info sisältää jo olennaiset tiedot
|
||||
fn enrich_apple_gpus(gpus: &mut [GpuInfo]) {
|
||||
// Apple Silicon -koneiden unified memory: koko RAM on GPU:n käytettävissä
|
||||
// Arvioidaan system RAM:sta
|
||||
@@ -187,13 +192,18 @@ fn enrich_apple_gpus(gpus: &mut [GpuInfo]) {
|
||||
|
||||
/// Kerää kaikki GPU:t ja täydentää valmistajakohtaiset tiedot
|
||||
fn collect_all_gpus() -> Vec<GpuInfo> {
|
||||
let mut gpus = collect_gpus_wgpu();
|
||||
|
||||
enrich_nvidia_gpus(&mut gpus);
|
||||
enrich_amd_gpus(&mut gpus);
|
||||
enrich_apple_gpus(&mut gpus);
|
||||
|
||||
gpus
|
||||
#[cfg(feature = "gpu-detect")]
|
||||
{
|
||||
let mut gpus = collect_gpus_wgpu();
|
||||
enrich_nvidia_gpus(&mut gpus);
|
||||
enrich_amd_gpus(&mut gpus);
|
||||
enrich_apple_gpus(&mut gpus);
|
||||
return gpus;
|
||||
}
|
||||
#[cfg(not(feature = "gpu-detect"))]
|
||||
{
|
||||
Vec::new()
|
||||
}
|
||||
}
|
||||
|
||||
/// Kerää järjestelmätiedot (CPU, RAM, OS)
|
||||
|
||||
Reference in New Issue
Block a user