Skip to content

Fix: gpu detection losing#7605

Open
dataCenter430 wants to merge 2 commits intojanhq:mainfrom
dataCenter430:fix/GPU-detection-losing
Open

Fix: gpu detection losing#7605
dataCenter430 wants to merge 2 commits intojanhq:mainfrom
dataCenter430:fix/GPU-detection-losing

Conversation

@dataCenter430
Copy link

Problem

After sleep (lid close or idle), Jan showed "No GPU detected" on Linux. The GPU still worked for display/HDMI, but model inference fell back to CPU.

Cause

  • Hardware/GPU info was cached once at startup (OnceLock) and never refreshed.
  • NVML was initialized once; after resume the driver state was reset and the handle became stale.

Solution

Backend (Rust)

  • Cache invalidation: Replaced OnceLock<SystemInfo> with RwLock<Option<SystemInfo>> so the cache can be cleared.
  • New command: refresh_system_info clears the cache and (on Linux) invalidates the NVML handle so the next detection re-initializes.
  • NVML: Switched to RwLock<Option<Nvml>> + with_nvml(); added invalidate_nvml() on Linux so NVML is re-inited after resume.

Frontend

  • API: Added refreshHardwareInfo() to the hardware service (no-op on web, invokes refresh_system_info on Tauri).
  • Auto-refresh: When the app window becomes visible again (e.g. after resume), we call refreshHardwareInfo() then re-fetch hardware and update the store (GlobalEventHandler + visibilitychange).
  • Manual refresh: Settings → Hardware → GPUs card has a "Refresh" button to re-detect GPUs on demand.

Testing

  • Linux (e.g. Zorin): sleep → wake → focus Jan → GPU should be detected again; or open Settings → Hardware and click Refresh.

Fixes Issues

Self Checklist

  • Added relevant comments, esp in complex areas
  • Updated docs (for bug fixes / features)
  • Created issues for follow-up changes or refactoring needed

@dataCenter430
Copy link
Author

dataCenter430 commented Mar 3, 2026

hey, @louis-jan @Vanalite how are you?
are you available to review the PR?
thank you.

@louis-jan
Copy link
Contributor

We will take a look

@louis-jan
Copy link
Contributor

Will take a bit more time to test across platforms. ETA: tmr

@dataCenter430
Copy link
Author

Will take a bit more time to test across platforms. ETA: tmr

okay, thanks.
pls let me know if you need anything.

@dataCenter430 dataCenter430 changed the title Fix/gpu detection losing Fix: gpu detection losing Mar 5, 2026
@dataCenter430
Copy link
Author

dataCenter430 commented Mar 5, 2026

Will take a bit more time to test across platforms. ETA: tmr

Hi, @louis-jan how are you? 👋
was the test completed?
I think it should be good, since everything looks fine on my end.

@dataCenter430
Copy link
Author

hey, are you available to review the PR?
thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

bug: Jan loses GPU detection after system sleep on Linux (Zorin)

2 participants