Repository navigation
Unsloth Studio installer (AMD/Windows): don't mistake ZLUDA for an NVIDIA GPU - #11736
Conversation
…en for an NVIDIA GPU The Windows driver-library probe bound nvcuda.dll by bare name and fell back to a bare nvml.dll, so the loader searched PATH. ZLUDA ships both DLLs and answers them as an NVIDIA driver, which made an RX 6800 host install torch 2.7.1+cu118. Name both by full path and bump the emitted type so a session that already built the bare-name one does not reuse it.
LeoBorcherding
left a comment
There was a problem hiding this comment.
Codex findings, via a mirror
Codex does not answer on this repository, so it ran against a copy of this pull request's commits at LeoBorcherding/unsloth-staging-review#18. It looked at 908be23cc6 there, which is this PR's 04169ebb6 replayed onto main 1ecc01a30. Nothing was reviewed or resolved on the copy: the findings are here, in Codex's words, to be worked through on this pull request.
Codex found no major issues. Its comment: https://github.com/LeoBorcherding/unsloth-staging-review/pull/18#issuecomment-5824889361
|
Review record for #11736, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#148. Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found. Round 1: reviewed mirror
|
…IDIA GPU (unslothai#11736) * Load the NVIDIA driver libraries by System32 path so ZLUDA is not taken for an NVIDIA GPU The Windows driver-library probe bound nvcuda.dll by bare name and fell back to a bare nvml.dll, so the loader searched PATH. ZLUDA ships both DLLs and answers them as an NVIDIA driver, which made an RX 6800 host install torch 2.7.1+cu118. Name both by full path and bump the emitted type so a session that already built the bare-name one does not reuse it. * Trim comments on the System32-pinned NVIDIA library probe --------- Co-authored-by: Daniel Han <[email protected]>
Why this PR (the short version)
Some AMD users on Windows get the wrong version of PyTorch from our installer: the NVIDIA one. Unsloth Studio then shows their AMD card as "detected, but PyTorch cannot use it", and training can't use the GPU at all.
The cause is a tool called ZLUDA. People install it to run NVIDIA-only apps (ComfyUI, Stable Diffusion) on AMD cards. It works by pretending to be an NVIDIA driver. Our installer asks Windows "is there an NVIDIA driver here?", ZLUDA says yes, and we install NVIDIA PyTorch on an AMD machine.
C:\Windows\System32) instead of searching every folder on PATH. Real NVIDIA machines find the same file as before.What changed
On Windows, the installer's NVIDIA driver-library probe (the fallback for when
nvidia-smiis missing) loadednvcuda.dllby bare name, and fell back to a barenvml.dll. A bare name makes Windows searchPATH, where ZLUDA puts its ownnvcuda.dllandnvml.dll, and those answer as an NVIDIA driver. The installer then printedNVIDIA GPU found through the driver library, pickedcu118, and installedtorch 2.7.1+cu118on an AMD-only machine.Reported in the Discord help thread: RX 6800, Windows 11, with an old ZLUDA folder on
PATHfrom before a reinstall. Taking it offPATHand rerunning the installer fixed it.nvcuda.dllis loaded from%SystemRoot%\System32by full path. The NVIDIA driver always installs it there, and with a bare name the loader already checked System32 beforePATH, so real NVIDIA hosts load the same file as before.nvml.dllexists, the fallback is now the System32 path instead of the bare name. The NVSMI location for older drivers is unchanged.UnslothNvidiaProbeV2toV3. Underirm | iex, a session that already built V2 would otherwise keep reusing its bare-name bindings.install.ps1andstudio/setup.ps1.studio/nvidia_probe.pyneeds no change, becausectypes.CDLLon Python 3.8+ doesn't searchPATH(checked: a barenvcuda.dllplaced only onPATHfails to load there).Before / after
Same box, same command. A stand-in
nvcuda.dll(a small Rust cdylib reporting one CUDA 11.8 device, the way ZLUDA answers) is prepended toPATH, andGet-NvidiaLibraryInventoryis run from each tree'sstudio/setup.ps1:upstream/maincc33d51{"Source":"cuda","CudaMajor":11,"CudaMinor":8,"Count":1}, so the installer picks cu118null: it triesC:\WINDOWS\System32\nvcuda.dll, finds nothing, and the host stays AMDHealthy direction: the same stand-in, placed in
<SystemRoot>\System32with nothing onPATH, is still found on PowerShell 7.6 ({"Source":"cuda","CudaMajor":11,...}, measured at c2ad507, before the merge of main, which didn't touch these functions). On 5.1,cuInitloads and returns 0 from the System32 path. The full 5.1 inventory couldn't be checked that way, because overridingSystemRootbreaks 5.1's child runspace (unmodified main returnsnullunder the same override).Run on an R9700, Windows 11 24H2, Windows PowerShell 5.1.26100 and PowerShell 7.6.6. This box has no NVIDIA driver, so a real NVIDIA host running through this branch hasn't been tested. A run on one (any driver, with
nvidia-smirenamed so the library path is taken) is the missing row.Tests
tests/studio/test_nvidia_library_inventory.ps1: the new helper joins the shared-block parity check. "No nvml.dll keeps the bare name" is now "names the System32 path", and a new check pinsnvcuda.dllto the System32 path. All checks pass at bb998ec.test_nvidia_smi_discovery.ps1passes at bb998ec.test_windows_installer_native_type_fallback.py,test_nvidia_library_probe.pyandtest_installer_av_shapes.pyat c2ad507: 366 pass. The same 7 fail on unmodifiedupstream/mainon this machine (symlink sweep and compile-watcher tests), so they don't come from this change.