Sign In

Lora Training on Windows? - Is it Doable?

29

Lora Training on Windows? - Is it Doable?

Lora Training on Windows? - Is it Doable?

Welcome to the one time I actually talk about an OS that I haven't used in years, and CURRENTLY still do not have a machine handy that runs this operating system. However in my dedication to support those that aren't on a Linux or Unix type machine setting when "vibe coding" and enslaving an LLM... erm um when i'm creating and designing programs -- yes that's the description...

Anyways IN ORDER TO SUPPORT y'all further - AND for me to learn more, I am dedicated to the idea of tech support for a LOT of my content I've been making. There are two sections on some basic discussion and information, and a third on the AI assisted solution that was given. This document won't likely be re-edited for clarification, this was just a sort of small shoot in the dark to help.

Section One:

What Options Do I have?

First of all there's a big difference in what graphics card you have in your PC, and what systems support. Sadly, I HAVE NO clue how Zluda or ROCm works for AMD, so this guide is largely going to sadly assume you have an NVIDIA card.

Reminder: I'm on a Mac, so i'm an "AMD" without the ability to train locally, becausei 'm on an intel mac, and even with the idea that i could put more ram in this, i'd still OOM on ComfyUI or even Forge, because I'm a nightmare.

You have several options if you're NVIDIA (again AMD can work some of these but I'm not sure how to instruct you on ROCM or Zluda.)

There ARE more than that, but those are a few. I've included mine because the guide is roughly tiered toward some issues you'll face on ANY system using Safetensors on windows.

What's a "SAFETENSOR"?

In short that's the file extension for a lora, embedding or even a large model. Before safetensors we had CKPT which was short I think for 'Checkpoint'. Exception to that was that anything with "PT" was largely considered "Pickled Tensor". Keep in mind this section is extremely short, so the full answer may not be 100%, and I have glossed over a lot of nuance and detail. Tensors are part of what is in any sort of LLM model, Image generation model - and "SAFE" was to denote that these models could RARELY if ever be used for malicious code.

Section Two:

Installation's simple-- wait no it's not!

So you've come to installing this on your windows machine, and you've come across some dreaded stop in the process. No, installations are never stupidly simple as easily just dropping an EXE file in and hitting install. A lot of machine learning and gen AI content is pythonic. It's based on python, and while it's extremely powerful, diverse and sometimes easy enough to program (if you manage to enslave an LLM) - package managment is a doozy.

You're likely running into several things:

  • GPU Driver Conflicts

  • Environment conflicts

  • Did i plug the monitor in or am i just staring at a black screen?

  • Path issues! (Python)

  • Path issues! (PIP/Python/Chocolatey etc)

  • Path Issues! (Rust/Cargo)

  • You don't even have PYTHON INSTALLED!

  • Pip is not installed.

  • You don't even have a computer!

  • Life is a simulation and my brain is frozen! (I'm writing this while it's still winter in NZ and we're having a fun stormy day where it's cold as balls.)

While I can't FULLY direct you to how to fix EVERY SINGLE ISSUE on this list I can note to you that if there's a PATH issue and you're NOT on a mac... You have a couple things you may have run into again:

  1. You install everything on a different drive than C.

  2. You have Rust installed for safetensors, but the path isn't picking up.

  3. You're on a PC with windows, but you're trying this on your laptop with Linux installed.

  4. You're on an AMD, and forgot that you need ROCM or Zluda.

A bit jokingly specific I know, but this isn't to call out anyone with #2- just for number one. KtiseosTerra still can't install any of my python toys that I've made because they install everything to the D drive. (Yea yea bring out your deez nuts jokes.)

Where as for issue number two, that's a bit more common for a path issue for windows.

Because I can't install AI services easily on my mac (because 8gb vram, 8gb system ram - no i can't even run diffusers on this thing.) - it's a 2019 Imac and I don't want to hear how Fp2 lora training is god and that i'll work you want me to trust the process. It's cheaper for me to rent GPU services then mess with my computer exploding.

Anyways, path issues are specific to the individual so I can't direct you to the specific fix I had for the user that had this issue. Especially because it may have 0% to do with rust, or cargo, or chocolatey or anything.

Rust thought is required to compile safetensors, and the pathing issue was the problem in both times the user presented to me.

Problem was: I didn't realize it the first time I told them. So they felt frustrated!

Work it out Developer!

Uh, no! Sadly and hear me out: Path issues are a user issue, but that doesn't mean the developer can't pull a helping hand to help the user understand how to fix it. ANYONE developing these sorts of services can't fix the safetensors install, or anything like that incase something breaks.

In the case example of my system (Found here) if I were to change ANY of the back end installation information between packages, i'd have to meticulously double check how each component works with one another. In this case? While i'm not naturally a programmer, trying to design a system that worked for me and anyone else - means that i'm having to instruct a machine code to pattern match their way through something... Only sometimes for it to assume it needs to make the solution on our end and edit the code so nothing works.

So it's not a Huggingface (Safetensors) issue, nor is it a KohyaSS issue. It's not even in theory the issue for the user in question. It's an accidental issue, you don't realize path issues are simply the bug that persists - like a cockroach!

Section Two:

Plausible solutions that were made by an AI

Disclaimer: This is ONLY for the specific error for Rust that was given to us by a user that was trying to install our system (again that's here) - and the current information is based on the situation the user was in. It was literally written by claude after we did some research:

=======================================================================

WINDOWS RUST TOOLCHAIN PATH TROUBLESHOOTING GUIDE

LoRA Easy Training Jupyter - Technical Support Document

=======================================================================

PROBLEM DESCRIPTION:

Your installation is failing during safetensors compilation because the Windows

PATH environment variable points to Rust parent directories (.cargo, .rustup)

instead of the executable directory (.cargo\bin) that contains cargo.exe and

rustc.exe. This is a common Windows Rust toolchain misconfiguration that occurs

when the installer is interrupted or runs with insufficient privileges.

SYMPTOMS:

- "ERROR: Failed building wheel for safetensors"

- "error: can't find Rust compiler"

- "cargo" command not found despite Rust being installed

- PATH contains C:\Users\%USERNAME%\.cargo but not C:\Users\%USERNAME%\.cargo\bin

=======================================================================

SOLUTION 1: IDEMPOTENT RUST TOOLCHAIN REPAIR (RECOMMENDED)

=======================================================================

This solution uses Rust's own toolchain manager to inspect and repair its PATH

configuration. This is the most robust method as it leverages official tooling.

STEPS:

1. Open PowerShell (Windows Terminal, PowerShell, or Command Prompt)

2. Execute rustup commands directly using full paths to force re-evaluation:

& "$env:USERPROFILE\.cargo\bin\rustup.exe" self update

& "$env:USERPROFILE\.cargo\bin\rustup.exe" show

& "$env:USERPROFILE\.cargo\bin\rustup.exe" default stable

3. Verify the toolchain is properly configured:

& "$env:USERPROFILE\.cargo\bin\cargo.exe" --version

& "$env:USERPROFILE\.cargo\bin\rustc.exe" --version

4. MANDATORY: Restart your terminal session completely. Existing terminal

sessions will not reload the PATH variable.

5. Verify resolution in the new terminal session:

cargo --version

6. Re-run the LoRA training installer:

python installer.py --verbose

RATIONALE:

- CLI-native solution that never leaves the terminal environment

- Idempotent - safe to run multiple times without side effects

- Uses official Rust toolchain manager to manage its own state

- Follows DevOps principle of using authoritative tools for state management

=======================================================================

SOLUTION 2: MANUAL PATH CORRECTION VIA POWERSHELL

=======================================================================

This solution provides granular control over the PATH environment variable

through direct PowerShell manipulation. Use when rustup commands are

unavailable or restricted by policy.

STEPS:

1. Inspect current User PATH to confirm the misconfiguration:

$oldPath = [Environment]::GetEnvironmentVariable("Path", "User")

$oldPath -split ';'

Look for incorrect entries: C:\Users\%USERNAME%\.cargo and C:\Users\%USERNAME%\.rustup

2. Construct the corrected PATH by filtering bad entries and adding correct one:

# Get current path as array

$pathArray = [Environment]::GetEnvironmentVariable("Path", "User") -split ';'

# Define the correct Rust executable path

$correctRustPath = "$env:USERPROFILE\.cargo\bin"

# Filter out incorrect Rust paths

$filteredPath = $pathArray | Where-Object {

$_ -ne "$env:USERPROFILE\.cargo" -and

$_ -ne "$env:USERPROFILE\.rustup"

}

# Add correct path with high priority (beginning of array)

$newPathArray = @($correctRustPath) + $filteredPath

# Join array back into PATH string

$newPath = $newPathArray -join ';'

3. Apply the corrected PATH permanently:

[Environment]::SetEnvironmentVariable("Path", $newPath, "User")

4. MANDATORY: Restart terminal session and verify:

cargo --version

5. Re-run the LoRA training installer:

python installer.py --verbose

RATIONALE:

- Provides complete transparency and control over PATH manipulation

- Scriptable - can be saved to PowerShell profile for automatic correction

- Educational - forces understanding of PATH structure and precedence

- Platform-native using Windows environment variable APIs

=======================================================================

SOLUTION 3: COMPLETE RUST ENVIRONMENT RESET

=======================================================================

Nuclear option for corrupted Rust installations or when other solutions fail.

This completely removes and reinstalls the Rust toolchain with proper PATH

configuration.

STEPS:

1. Complete Rust uninstallation (if rustup is accessible):

& "$env:USERPROFILE\.cargo\bin\rustup.exe" self uninstall -y

2. Manual PATH cleanup to remove all Rust references:

$pathArray = [Environment]::GetEnvironmentVariable("Path", "User") -split ';'

$cleanPath = $pathArray | Where-Object {

$_ -notlike "*cargo*" -and $_ -notlike "*rustup*"

}

[Environment]::SetEnvironmentVariable("Path", $cleanPath -join ';', "User")

3. Fresh Rust installation with proper configuration:

Invoke-WebRequest -Uri "https://win.rustup.rs/" -OutFile "rustup-init.exe"

.\rustup-init.exe -y --default-host x86_64-pc-windows-msvc --default-toolchain stable

Remove-Item "rustup-init.exe"

4. MANDATORY: Restart terminal session or run refreshenv if available

5. Verify complete toolchain functionality:

cargo --version

rustc --version

6. Re-run the LoRA training installer:

python installer.py --verbose

RATIONALE:

- Guarantees clean state by removing all previous configuration

- Uses official Rust installer with known-good default settings

- Eliminates accumulated configuration corruption from failed installs

- Provides highest success rate for complex environment issues

=======================================================================

DIAGNOSTIC COMMANDS

=======================================================================

Run these commands to generate diagnostic information for further troubleshooting:

# Comprehensive Rust environment analysis

Write-Host "=== RUST DIAGNOSTICS ==="

Write-Host "PATH entries containing rust/cargo:"

$env:PATH -split ';' | Where-Object { $_ -like "*rust*" -or $_ -like "*cargo*" }

Write-Host "`nDirect executable tests:"

Test-Path "$env:USERPROFILE\.cargo\bin\cargo.exe"

Test-Path "$env:USERPROFILE\.cargo\bin\rustc.exe"

Write-Host "`nCommand resolution:"

Get-Command cargo -ErrorAction SilentlyContinue

Get-Command rustc -ErrorAction SilentlyContinue

Write-Host "`nSafetensors installation test:"

python -c "import safetensors; print('SUCCESS: safetensors already installed')" 2>$null

if ($LASTEXITCODE -ne 0) {

Write-Host "FAILED: safetensors not installed or importable"

}

Write-Host "`nPython and pip versions:"

python --version

python -m pip --version

=======================================================================

TECHNICAL NOTES

=======================================================================

ROOT CAUSE:

The Rust installer modifies the User PATH environment variable to include

C:\Users\%USERNAME%\.cargo\bin for executable access. When this process is

interrupted or runs with insufficient privileges, it may incorrectly add parent

directories (.cargo, .rustup) instead of the bin subdirectory containing the

actual executables.

SAFETENSORS CONTEXT:

The safetensors==0.4.4 Python package requires Rust compilation during

installation via pip. When cargo and rustc are not accessible due to PATH

misconfiguration, pip attempts to build from source and fails with compiler

not found errors.

ENVIRONMENT IMPACT:

- Affects Windows User PATH (not System PATH)

- Requires terminal restart to reload environment variables

- Does not affect existing terminal sessions

- Changes persist across system reboots

COMPATIBILITY:

- Solutions work on Windows 10 and Windows 11

- Compatible with PowerShell 5.1+ and PowerShell Core 7+

- Works with both Windows Terminal and legacy Command Prompt

- Safe to use with existing Python virtual environments

29

Comments