# Local Model Backups

**URL:** <https://discuss.huggingface.co/t/local-model-backups/171119>\
**Category:** Beginners\
**Created:** [December 3, 2025, 8:21pm UTC](https://discuss.huggingface.co/t/local-model-backups/171119 "2025-12-03T20:21:08Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![OnlyFakes-AI](https://avatars.discourse-cdn.com/v4/letter/o/b77776/32.png) [@OnlyFakes-AI](https://discuss.huggingface.co/u/OnlyFakes-AI)\
**Post date:** [December 3, 2025, 8:21pm UTC](https://discuss.huggingface.co/t/local-model-backups/171119/1 "2025-12-03T20:21:08Z")

</div>

Hey guys, im having trouble with local backups and it’s getting slighty (a LOT) annoying to have to redownload the models everytime.

They seem to become corrupted once i move them, or back them up locally. The only fix is the redownload them, copying them from a cold backup doesnt work.

Does anyone know how to safely store models LOCALLY, what filesystem type is best ? And why they are getting corrupted for NO reasons.

Thanks 😃

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [December 3, 2025, 11:58pm UTC](https://discuss.huggingface.co/t/local-model-backups/171119/2 "2025-12-03T23:58:15Z")

</div>

First, have you downloaded it correctly? The download method is quite confusing, so this part causes a lot of trouble…😅

* * *

The safest way to store Hugging Face models locally is to separate two things in your mind:

1. The **shared cache** (managed automatically by Hugging Face libraries).
2. Your own **“model store” directories** (folders you control, back up, and load from).

If you treat the cache as internal scratch space and only back up clean model folders, you avoid most corruption and confusion.

Below is a step-by-step, beginner-safe approach.

* * *

## 1. Background: how Hugging Face stores things on your machine

When you do something like:

```python
from transformers import AutoModel, AutoTokenizer
model = AutoModel.from_pretrained("bert-base-uncased")
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")

```

internally the libraries:

1. Download the files from the Hub (weights, config, tokenizer).
2. Store them in a **versioned cache directory** on disk (by default something like `~/.cache/huggingface/hub`). ([Hugging Face](https://huggingface.co/docs/huggingface_hub/en/guides/manage-cache "Understand caching"))
3. Next time, load directly from that cache instead of re-downloading. ([Hugging Face](https://huggingface.co/docs/huggingface_hub/en/quick-start "Quickstart"))

The low-level download function `hf_hub_download()` explicitly says:

- It downloads a file,
- Caches it,
- Returns a **path into the cache** that must **not** be modified, otherwise the cache can be corrupted. ([Hugging Face](https://huggingface.co/docs/huggingface_hub/en/guides/download "Download files from the Hub"))

So:

- **Cache** = shared internal storage, ephemeral, auto-managed.
- **Your model folders** = self-contained directories you create for long-term storage and backups.

Storing models “properly” means:

- Let the cache do its job.
- Create **explicit local model directories** for anything important.
- Store/backup **those directories** , not random cache internals.

* * *

## 2. Decide where your local models live

Pick one root folder on a reliable disk, for example:

- Linux/macOS: `/home/you/models` or `/mnt/bigdisk/hf-models`
- Windows: `D:\hf-models`

Inside this root you will have one subfolder per model, e.g.:

- `/home/you/models/bert-base-uncased`
- `/home/you/models/meta-llama-3-8b`
- `D:\hf-models\sdxl-base`

You will then:

- Download or export models into those subfolders.
- Load models from those folders.
- Backup those folders (zip/tar/copy).

* * *

## 3. Method A (Python): load once, then save with `save_pretrained`

This is very simple and beginner-friendly.

### 3.1 Download and save

```python
from transformers import AutoModel, AutoTokenizer

model_id = "bert-base-uncased"
local_dir = "/home/you/models/bert-base-uncased" # adjust path

tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModel.from_pretrained(model_id)

tokenizer.save_pretrained(local_dir)
model.save_pretrained(local_dir)

```

What this does:

- `from_pretrained(model_id)` downloads into the cache (if not present yet). ([Hugging Face](https://huggingface.co/docs/transformers/en/models "Loading models"))
- `save_pretrained(local_dir)` writes a **complete copy** into your chosen folder (config + weights + tokenizer files). ([Hugging Face](https://huggingface.co/docs/transformers/en/main_classes/model "Models"))

Now `/home/you/models/bert-base-uncased` is your **stored local model**.

### 3.2 Load from that folder later (offline-friendly)

```python
from transformers import AutoModel, AutoTokenizer

local_dir = "/home/you/models/bert-base-uncased"

tokenizer = AutoTokenizer.from_pretrained(local_dir)
model = AutoModel.from_pretrained(local_dir)

```

`from_pretrained` accepts either a model name (Hub) or a **local directory path** as long as that directory contains a valid `config.json` and the weight files. ([Hugging Face](https://huggingface.co/docs/transformers/en/main_classes/model "Models"))

This pattern is the official way to store models on disk and reload them.

* * *

## 4. Method B (Python): use `snapshot_download` as a “repo snapshot”

If you want a directory that mirrors the **entire Hub repo** (including extra files like README, merges, Lora adapters, etc.), the Hub library has `snapshot_download()`.

### 4.1 Download a full repo into a folder

```python
from huggingface_hub import snapshot_download

repo_id = "bert-base-uncased"
local_dir = "/home/you/models/bert-base-uncased"

snapshot_download(
    repo_id=repo_id,
    local_dir=local_dir,
    local_dir_use_symlinks=False, # important for portable storage
)

```

- `snapshot_download` pulls all files for that repo and revision, and caches them. ([Hugging Face](https://huggingface.co/docs/huggingface_hub/v0.18.0.rc0/en/guides/download "Download files from the Hub"))
- `local_dir` tells it to also create a **full working copy** in your chosen folder. ([Hugging Face](https://huggingface.co/docs/huggingface_hub/v0.17.0.rc0/en/guides/download "Download files from the Hub"))
- `local_dir_use_symlinks=False` forces **real files** instead of symlinks pointing into the cache; this is better for backups and moving to other machines. ([Hugging Face](https://huggingface.co/docs/huggingface_hub/v0.22.1/en/package_reference/file_download "Downloading files"))

### 4.2 Load from that directory

```python
from transformers import AutoModel, AutoTokenizer

local_dir = "/home/you/models/bert-base-uncased"

tokenizer = AutoTokenizer.from_pretrained(local_dir)
model = AutoModel.from_pretrained(local_dir)

```

Same idea as in Method A: you always load from the directory, not from arbitrary cache paths.

* * *

## 5. Method C (CLI): `hf download --local-dir`

If you prefer the command line, the `hf` CLI (from `huggingface_hub`) can download a model directly into your model store folder.

### 5.1 Install the CLI

```bash
pip install -U huggingface_hub
hf --help

```

The docs describe `hf download` as the recommended way to download files from the Hub via CLI, with an optional `--local-dir` for a git-like “working directory” workflow. ([Hugging Face](https://huggingface.co/docs/huggingface_hub/v0.34.0/en/guides/cli "Command Line Interface (CLI)"))

### 5.2 Download an entire model repo to a local dir

```bash
hf download meta-llama/Meta-Llama-3-8B-Instruct \
  --local-dir "/home/you/models/llama3-8b"

```

This:

- Downloads the whole repo.
- Uses the cache system under the hood.
- Creates `/home/you/models/llama3-8b` with the files plus a small internal `.cache/huggingface` subfolder for metadata. ([Hugging Face](https://huggingface.co/docs/huggingface_hub/v0.34.0/en/guides/cli "Command Line Interface (CLI)"))

Later in Python:

```python
from transformers import AutoModelForCausalLM, AutoTokenizer

model_dir = "/home/you/models/llama3-8b"
tokenizer = AutoTokenizer.from_pretrained(model_dir)
model = AutoModelForCausalLM.from_pretrained(model_dir)

```

Again: local directory → `from_pretrained(local_dir)`.

* * *

## 6. How this relates to the cache (and when to move it)

### 6.1 Where the cache is by default

The Hub cache lives by default under `~/.cache/huggingface/hub` (or the OS-specific equivalent). ([Hugging Face](https://huggingface.co/docs/huggingface_hub/en/guides/manage-cache "Understand caching"))

You can change its location by:

- Passing `cache_dir=` arguments to download/functions, or
- Setting environment variables like `HF_HOME`, `HUGGINGFACE_HUB_CACHE`, or `TRANSFORMERS_CACHE` so the libraries use a different root. ([Hugging Face](https://huggingface.co/docs/huggingface_hub/en/guides/manage-cache "Understand caching"))

Changing `HF_HOME`, for example, moves where the Hub libraries keep both the token and the cache. ([Hugging Face](https://huggingface.co/docs/huggingface_hub/en/package_reference/environment_variables "Environment variables"))

### 6.2 Important rule: do not edit cache files

The low-level docs are explicit that `hf_hub_download` returns a path that is a pointer into this cache and **you should not modify those files** because you risk corrupting the cache. ([Hugging Face](https://huggingface.co/docs/huggingface_hub/en/guides/download "Download files from the Hub"))

So:

- Use the cache as built-in storage for “whatever you happen to download”.
- Use your **model store folders** for anything you care about long term.

If the cache becomes messy or too large, the CLI provides commands like `hf cache info` and `hf cache delete/clear` to clean it up (and `hf cache verify` to check files against checksum). ([Hugging Face](https://huggingface.co/docs/huggingface_hub/main/en/guides/cli "Command Line Interface (CLI)"))

* * *

## 7. Backing up and verifying local model folders

Once you have a folder per model under your chosen root, you can treat them like any other assets:

1. **Backup strategy**

2. **Verification**

3. **Restoration**

No interaction with the cache is strictly required for restore, as long as the folder is complete.

* * *

## 8. Quick, concrete recipes

### 8.1 Minimal Python-only recipe (beginner-friendly)

1. Choose root:

2. Download + save:

3. Later, load from disk:

### 8.2 Minimal CLI + Python recipe

1. Download via CLI:

2. Use in Python:

(For plain Transformers models you would use `AutoModel` / `AutoTokenizer`, same as above.)

* * *

## Short bullet summary

- Hugging Face models are stored in a **cache** by default (`~/.cache/huggingface/hub`), managed by Hub libraries and configurable via environment variables like `HF_HOME` and `TRANSFORMERS_CACHE`. ([Hugging Face](https://huggingface.co/docs/huggingface_hub/en/guides/manage-cache "Understand caching"))

- Cache paths returned by `hf_hub_download` are **pointers to that cache** and must not be edited directly. ([Hugging Face](https://huggingface.co/docs/huggingface_hub/en/guides/download "Download files from the Hub"))

- To “store models locally properly”, create your own **model store root directory** , and for each model:

- Always load offline with `from_pretrained("/path/to/folder")`, not with random cache paths. ([Hugging Face](https://huggingface.co/docs/transformers/en/main_classes/model "Models"))

- Back up these model folders (zip/tar, copy) just like any other large project directory, and optionally verify them using hashes or `hf cache verify`. ([Hugging Face](https://huggingface.co/docs/huggingface_hub/main/en/guides/cli "Command Line Interface (CLI)"))

---

<div class="post-metadata">

**Author:** ![OnlyFakes-AI](https://avatars.discourse-cdn.com/v4/letter/o/b77776/32.png) [@OnlyFakes-AI](https://discuss.huggingface.co/u/OnlyFakes-AI)\
**Post date:** [December 4, 2025, 10:19pm UTC](https://discuss.huggingface.co/t/local-model-backups/171119/3 "2025-12-04T22:19:06Z")

</div>

Hi,

thanks for your reply, im quite new and noob to this. I just click download and save them to my drive.

They work fine, until i back them up the start producing black outputs.

I tried NTFS file system and ExFAT and same results.

I have never used anything you mentioned as i have no idea what it is.

I just want local backup and not use your precious storage space.

Thank you 😃

---

<div class="post-metadata">

**Author:** ![OnlyFakes-AI](https://avatars.discourse-cdn.com/v4/letter/o/b77776/32.png) [@OnlyFakes-AI](https://discuss.huggingface.co/u/OnlyFakes-AI)\
**Post date:** [December 4, 2025, 10:27pm UTC](https://discuss.huggingface.co/t/local-model-backups/171119/4 "2025-12-04T22:27:46Z")

</div>

Just want to add,

Im talking about LoRa’s

Nothing too crazy. Most of them are available on CIVITAI but when something goes wrong and i have to reinstall them it becomes a pain, that’s why i simply want to store them locally.

I think you must be talking about something else.

thanks

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [December 5, 2025, 2:08am UTC](https://discuss.huggingface.co/t/local-model-backups/171119/5 "2025-12-05T02:08:49Z")

</div>

Ah, so you mean that “file system”…

FAT32 might have capacity limits, but NTFS or ExFAT are more lenient. I actually use NTFS myself and haven’t encountered any issues.  
If something seems like it might go wrong, I’d guess the cause lies elsewhere besides the file system.

---

<div class="post-metadata">

**Author:** ![OnlyFakes-AI](https://avatars.discourse-cdn.com/v4/letter/o/b77776/32.png) [@OnlyFakes-AI](https://discuss.huggingface.co/u/OnlyFakes-AI)\
**Post date:** [December 5, 2025, 3:31am UTC](https://discuss.huggingface.co/t/local-model-backups/171119/6 "2025-12-05T03:31:04Z")

</div>

I don’t know, i can download the lora fine, and upload them fine to huggingface and use them fine.

But as soon as i have to reinstall comfyui because their updates always break everything, or as soon as i make a backup of the models to my external drive. They are broken and will create NaN errors.

And it’s been very consistant, tried multiple file systems and backups always breaks. That’s why im just trying to be able to store them safely somewhere and not online.

I thought i was missing something and i probably am since nothing else is being corrupted on my pc.

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [December 6, 2025, 12:59am UTC](https://discuss.huggingface.co/t/local-model-backups/171119/7 "2025-12-06T00:59:49Z")

</div>

Hmm… I considered the possibility of hardware damage, but if reinstalling ComfyUI would definitely break it, doesn’t that mean the ComfyUI environment is corrupted while the files themselves might still be intact?

* * *

Short answer:  
Your LoRAs are almost certainly not “randomly rotting”. What is happening is usually one of:

1. The files are getting slightly corrupted when you copy them to / from the external drive.
2. ComfyUI changes (after reinstall/update) make the same LoRA + model combo start producing NaNs, even though the file itself is fine.
3. Paths and folders get mixed up after reinstall so ComfyUI is not actually using the file you think it is.

You can fix this with:

- One safe, permanent “models” folder on your PC.
- Backups as ZIP/7z archives that you test.
- A quick hash check (file fingerprint) to prove if a backup is really identical.
- Treating ComfyUI as disposable, not your model files.

Below is a detailed, beginner-safe breakdown.

* * *

## 1. Background: what is actually stored where

### 1.1 Hugging Face side

Hugging Face libraries use two layers: ([Hugging Face Forums](https://discuss.huggingface.co/t/local-model-backups/171119 "Local Model Backups - Beginners - Hugging Face Forums"))

1. **Cache**

2. **Your own model folders**

The Hugging Face “Local Model Backups” thread says exactly this: treat the cache as internal scratch space and only back up clean model folders you control. ([Hugging Face Forums](https://discuss.huggingface.co/t/local-model-backups/171119 "Local Model Backups - Beginners - Hugging Face Forums"))

### 1.2 ComfyUI side

ComfyUI also uses a folder tree of model files: checkpoints, LoRAs, VAEs, etc. By default they sit under `ComfyUI\models\...`. The official docs say you can move your real models outside of ComfyUI and point ComfyUI at them via an `extra_model_paths.yaml` file. ([ComfyUI](https://docs.comfy.org/development/core-concepts/models "Models"))

Key idea:

> Your LoRAs and checkpoints should live in one central folder that you own.  
> ComfyUI should just _reference_ that folder.

Once you do that, reinstalling ComfyUI does not touch your model files at all.

* * *

## 2. Possible causes of your “corruption”

### 2.1 Partial or bad copies to / from the external drive

**What happens**

LoRA files (`.safetensors`) are big binary files. If:

- The USB cable is flaky.
- The external drive has errors.
- You unplug the drive too early.
- You copy while something is still downloading.

then the copy can be truncated (shorter than it should be) or slightly damaged.

The safetensors library then throws errors like:

> “The safetensors file is incomplete. Check the file size and make sure you have copied/downloaded it correctly.”

This exact message appears in a ComfyUI GitHub issue where a model copied into `ComfyUI/models/controlnet/...` was incomplete; safetensors raised `MetadataIncompleteBuffer`. ([GitHub](https://github.com/comfyanonymous/ComfyUI/issues/6744 "The safetensors file is incomplete · Issue #6744"))

Sometimes the file is “valid enough” to load, but the weights are garbage, and later the UNet math blows up and you see NaNs.

**Why this matches your case**

- Fresh download works.
- Copy to external and back → NaNs / black outputs.
- Re-download fixes it.

That is exactly the pattern of a copy that is not bit-identical to the original.

**How to recognise**

- Sometimes you get an explicit ComfyUI error like above instead of just NaNs. ([GitHub](https://github.com/comfyanonymous/ComfyUI/issues/6744 "The safetensors file is incomplete · Issue #6744"))
- File size of a “bad” copy is smaller than the original.
- A checksum (hash) of the file changes after copy (more on this in solutions).

* * *

### 2.2 Backing up the wrong thing (cache vs real model folders)

If you ever copy:

- Random subfolders from `~/.cache/huggingface/hub` (or Windows equivalent).
- Symlinked files instead of the real file.
- Temporary download folders.

you can easily end up with:

- Half a model.
- Only one shard of a sharded model.
- Symlinks that point to nothing on the new machine.

The Hugging Face docs and the local backups answer say:

- Cache paths returned by `hf_hub_download` are pointers into the cache and **must not be edited**. ([Hugging Face Forums](https://discuss.huggingface.co/t/local-model-backups/171119 "Local Model Backups - Beginners - Hugging Face Forums"))
- For long-term storage you should create your own per-model folder using `save_pretrained`, `snapshot_download(local_dir=..., local_dir_use_symlinks=False)`, or `hf download --local-dir`. ([Hugging Face Forums](https://discuss.huggingface.co/t/local-model-backups/171119 "Local Model Backups - Beginners - Hugging Face Forums"))

If you back up random cache internals instead of those clean folders, you will see exactly the kind of weird behaviour you describe.

Your note “I just click download and save them to my drive” suggests you may be fine here, but it is worth knowing: do not copy HF cache directories around as “backups”.

* * *

### 2.3 ComfyUI reinstall changes the environment → NaNs

NaNs in the UNet are very common when:

- The GPU is near its limits.
- Precision is too low (lots of fp16 under tight VRAM).
- xFormers or other optimisations change.
- PyTorch / CUDA versions change.

The classic error text (from AUTOMATIC1111, Hugging Face and others) is: ([GitHub](https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/6923 "[Bug]: A tensor with all NaNs was produced in Unet #6923"))

> “NansException: A tensor with all NaNs was produced in Unet.  
> This could be either because there’s not enough precision to represent the picture, or because your video card does not support half type. Try setting ‘Upcast cross attention layer to float32’ or using the `--no-half` command line argument…”

Many people see this after only changing:

- WebUI / ComfyUI version.
- Driver version.
- Optimisation settings.

They do not change the model file at all, but NaNs appear.

**Why this fits your story**

You said:

> “As soon as I have to reinstall ComfyUI… they are broken and will create NaN errors.”

If after reinstall:

- The **same** LoRA file from before now triggers NaNs,
- And your backup copy has the same size and hash as the original,

then nothing is “corrupted”. The math environment changed and became less stable.

* * *

### 2.4 Wrong model + LoRA combination after restore

If you mix:

- LoRAs for SD1.5 with SDXL or Flux base models.
- ControlNet models built for different base models.
- Wrong VAEs.

you can get:

- Shape mismatch errors, or
- Very unstable activations that lead to NaNs.

After a reinstall, it is easy for ComfyUI to:

- Point to a different default checkpoint.
- Forget some custom paths.
- Load a different VAE or text encoder.

Then a workflow that used to be “LoRA X + base model Y” becomes “LoRA X + base model Z”, which might blow up numerically even if both files are individually fine.

* * *

### 2.5 External drive or cable issues

If the external drive or USB path is flaky, the damage will **only** show up on large files. Small text files are usually fine.

This is why it can feel like “only LoRAs get corrupted”:

- They are large.
- They are compressed binary formats.
- A tiny error in a large `.safetensors` often causes the loader to fail or the network to produce NaNs.

Tools like 7-Zip have a `t` (test) command specifically to check archive integrity. ([7-zip.opensource.jp](https://7-zip.opensource.jp/chm/cmdline/commands/test.htm "t (Test integrity of archive) command"))

If testing a big `.7z` archive on your external drive ever shows errors, then the drive/cable/port is not safe for these backups.

* * *

## 3. Safe setup and solutions (PC-beginner friendly)

### 3.1 Step 1: Pick one permanent “models” folder

On Windows:

1. Open File Explorer.

2. Choose a drive with free space (for example `D:`).

3. Create:

This is your **main** model store. Do not put ComfyUI itself in here. This folder is what you back up and restore.

### 3.2 Step 2: Tell ComfyUI to use that folder

You want ComfyUI to _look_ into `D:\AI\models` instead of storing everything inside its own directory.

ComfyUI docs and guides say to use `extra_model_paths.yaml` for this on Windows: ([GitHub](https://github.com/comfyanonymous/ComfyUI/blob/master/extra_model_paths.yaml.example "ComfyUI/extra\_model\_paths.yaml.example at master"))

1. Go to your ComfyUI install folder, something like:

2. Find `extra_model_paths.yaml.example`.

3. Copy it and rename the copy to:

4. Open `extra_model_paths.yaml` in Notepad.

5. Add something like:

6. Move your existing models into these folders:

7. Start ComfyUI and press `r` in the UI to refresh models. ([Blender Neko](https://blenderneko.github.io/ComfyUI-docs/ "ComfyUI Community Manual - GitHub Pages"))

Now:

- You can delete and reinstall ComfyUI as many times as you want.
- Your models stay in `D:\AI\models` and do not move.

### 3.3 Step 3: Download and store LoRAs correctly

For LoRAs from Civitai or similar:

- When you click download in the browser, **save directly** into `D:\AI\models\loras`.
- Wait for the download to fully finish before closing the browser or moving the file.
- Do not move the file again unless you really have to.

If you ever use Hugging Face Hub via Python or CLI, the “Local Model Backups” answer recommends: ([Hugging Face Forums](https://discuss.huggingface.co/t/local-model-backups/171119 "Local Model Backups - Beginners - Hugging Face Forums"))

- Use `snapshot_download(..., local_dir=..., local_dir_use_symlinks=False)` or
- Use `hf download <repo> --local-dir D:\AI\models\some-model`

so that your real model copy is in your own folder, not just the cache.

### 3.4 Step 4: Back up models as archives and test them

Instead of copying hundreds of `.safetensors` individually:

1. Install 7-Zip if you do not have it.

2. Right-click `D:\AI\models` → 7-Zip → “Add to models\_backup.7z”.

3. After it finishes, test the archive:

4. If test passes, copy `models_backup.7z` to your external drive.

5. On the external drive, run the test again.

If the test fails **only on the external copy** , the drive or cable is causing corruption.

When you need to restore:

1. Copy `models_backup.7z` from external back to your PC.
2. Test it again with 7-Zip.
3. If it passes, extract it into `D:\AI\models`.

Now all the LoRAs and checkpoints are back in the exact same paths ComfyUI expects.

### 3.5 Step 5: Simple “file fingerprint” check (hash) on Windows

To prove a single LoRA file is identical before and after backup:

1. Open **Command Prompt**.

2. Run:

3. Copy the same file to your external drive, e.g. `E:\backups\my_lora.safetensors`.

4. Run:

5. Compare the two hashes:

Do the same after copying back from external to see if the round trip is safe.

* * *

### 3.6 Step 6: When you see NaNs, separate “corruption” from “math problems”

When ComfyUI says:

> “NansException: A tensor with all NaNs was produced in Unet…” ([GitHub](https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/6923 "[Bug]: A tensor with all NaNs was produced in Unet #6923"))

use this simple checklist:

1. **Test with a base model only**

2. **Add one LoRA at a time**

3. **If hashes match but NaNs only appear on new ComfyUI builds**

* * *

## 4. Very short checklist

- **Cause 1 (common):** copies to external drive are incomplete or damaged → safetensors error or NaNs.

- **Cause 2:** backing up or moving HF cache internals instead of clean model folders.

- **Cause 3:** ComfyUI reinstall / update changes GPU math and precision → NaNs with same model.

- **Cause 4:** wrong mixes (wrong base model + LoRA + ControlNet) after reinstall.

If you set up the single “models” folder, use archives for backup, and verify with hashes, you should reach a point where you never need to re-download the same LoRA again unless the original download itself was bad.

---

<div class="post-metadata">

**Author:** ![OnlyFakes-AI](https://avatars.discourse-cdn.com/v4/letter/o/b77776/32.png) [@OnlyFakes-AI](https://discuss.huggingface.co/u/OnlyFakes-AI)\
**Post date:** [December 6, 2025, 1:54am UTC](https://discuss.huggingface.co/t/local-model-backups/171119/8 "2025-12-06T01:54:47Z")

</div>

Thanks, i don’t understand what you mean by /cache or whatever, i only have .saftensors files.

Well it has to be the models that are corrupted since installing the SAME models from huggingface will fix the black output issue.

So you are saying, downloading all the models and putting them in a zip file will fix the issue ? The only annoying thing about this is that i often need to backup new models. I really thought simply leaving them in a folder would be good enough.

I was also using robocopy to copy the files with the same outcome.

It also can’t be a wrong model/lora combo, ive sucessfully generated over 2000 hours of videos with my workflows.

It’s just so annoying to not be able to properly store them.

I appreciate your complete answers and i will try to put them in a zip before backing them up and see what happens next time i need a fresh install.

Thank you very much

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [December 6, 2025, 2:01am UTC](https://discuss.huggingface.co/t/local-model-backups/171119/9 "2025-12-06T02:01:04Z")

</div>

Hmm… Zipping it up is more of a management issue, so I don’t think it really matters whether you do it or not. It doesn’t compress much anyway…

I think every time you reinstall ComfyUI, it loses track of the safetensors file location and throws a `NaN`. Basically, I think ComfyUI’s settings are messed up. Otherwise, it should break even without reinstalling ComfyUI.  
But since I’m not a ComfyUI user myself, I can’t tell what’s wrong without asking the AI…

---

<div class="post-metadata">

**Author:** ![OnlyFakes-AI](https://avatars.discourse-cdn.com/v4/letter/o/b77776/32.png) [@OnlyFakes-AI](https://discuss.huggingface.co/u/OnlyFakes-AI)\
**Post date:** [December 7, 2025, 7:06am UTC](https://discuss.huggingface.co/t/local-model-backups/171119/10 "2025-12-07T07:06:55Z")

</div>

I’ve tried the AI, yeah if it was comfyUI that lost track a fresh install wouldnt have that problem… but it does, that’s why im lost

The AI did tell me about the ZIP thing, which i still havent tried yet. It’s basically the last thing it could be according to it. I basically spend so much time download models locally thinking i have a strong backup only for them to no longer work and produce NaN’s when anything happens to my install.

(even simply copying the entire comfyui folder will completely break the original comfyui install…but not the copied one) That’s a head scratcher in itself

---

<div class="post-metadata">

**Author:** ![xiaokang-cinq](https://avatars.discourse-cdn.com/v4/letter/x/4da419/32.png) [@xiaokang-cinq](https://discuss.huggingface.co/u/xiaokang-cinq)\
**Post date:** [December 7, 2025, 10:01am UTC](https://discuss.huggingface.co/t/local-model-backups/171119/11 "2025-12-07T10:01:28Z")

</div>

默认的文件夹位置最好不要移动。

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [December 7, 2025, 3:12pm UTC](https://discuss.huggingface.co/t/local-model-backups/171119/12 "2025-12-07T15:12:39Z")

</div>

Not just ComfyUI, but generative AI-related software often relies on various other programs running in the background. Simply reinstalling using Windows features rarely creates a clean environment. Furthermore, when using other software, they often negatively impact each other. That’s one reason virtual environments are frequently used.

For ComfyUI, if you’re someone who reinstalls often, wouldn’t it be better to just use the Portable version in the first place…

Portable versions exist for many software programs. Essentially, they’re standalone packages that run within a folder, minimizing implicit environment settings like the registry or `AppData`. This makes them less prone to reinstallation issues.

* * *

If we assume:

- Your model / LoRA files are OK on disk, and
- Your drives / file systems are not dying,

then the problems have to come from **ComfyUI itself** : how it is configured, where it looks for models, and how it runs them on your GPU.

On Windows there are four main causes, and yes, the **Portable** version usually makes this easier to control.

* * *

## 1. “Fresh install” is not really fresh (Windows config outside the folder)

On Windows, ComfyUI Desktop stores settings **outside** the install folder, under your user profile:

```plaintext
C:\Users\<You>\AppData\Roaming\ComfyUI\

```

This folder holds things like:

- model paths (`extra_model_paths.yaml` / `extra_models_config.yaml`)
- other app settings ([Reddit](https://www.reddit.com/r/comfyui/comments/1ji62q8/how_to_change_the_default_comfyui_folder_location/ "How to Change the Default ComfyUI Folder Location in ..."))

GitHub reports show that uninstalling ComfyUI Desktop does **not** delete all of this AppData stuff, so “reinstall” often reuses old config. ([GitHub](https://github.com/comfyanonymous/ComfyUI/issues/8992 "Uninstalling the ComfyUI Desktop app does not clean all of ..."))

That explains your weird case:

> copying the entire ComfyUI folder breaks the original, but not the copied one

Both installs may be reading the **same** AppData config, which now points at paths that fit the copy better than the original.

### Solution (plain steps)

If you ever want a _truly fresh_ ComfyUI Desktop:

1. Close ComfyUI.

2. Uninstall or delete the Desktop app folder.

3. Delete or rename:

4. Reinstall Desktop.

5. Re-set the model path (see section 3).

After that, the “new” install is really new. No hidden old config.

* * *

## 2. Path confusion + duplicate models

If you have models in more than one place, ComfyUI can load a _different_ file with the same name depending on install and config.

Typical situation:

- Old location: `C:\ComfyUI\models\loras\my_lora.safetensors`
- New location: `D:\AI\models\loras\my_lora.safetensors`

If `extra_model_paths.yaml` or Desktop config reference both locations, ComfyUI will scan multiple folders. After reinstall:

- Search order can change.
- One install might pick the old `C:` copy; another picks `D:` copy.
- One of those copies might be incomplete, outdated or wrong model-family.

Result: “sometimes it works, sometimes NaNs” with the same LoRA name, but not the same file.

ComfyUI docs and guides for Windows show that you should either:

- use the **default** `models` folder under ComfyUI, or
- point `base_path` to a **single central folder** using `extra_model_paths.yaml` / `extra_models_config.yaml`. ([docs.comfy.org](https://docs.comfy.org/installation/comfyui_portable_windows "ComfyUI(portable) Windows"))

### Solution (plain steps)

1. Decide on one model root, for example:

2. Move **all** your checkpoints and LoRAs into those folders.

3. Delete duplicate `.safetensors` in any other `ComfyUI\models\...` directories.

4. Configure ComfyUI to use only this root:

Now every ComfyUI you run is forced to use the same clean set of models.

* * *

## 3. NaNs from GPU / precision, not from broken files

The classic Stable Diffusion error is:

> `NansException: A tensor with all NaNs was produced in Unet.`  
> “This could be either because there’s not enough precision to represent the picture, or because your video card does not support half type. Try setting ‘Upcast cross attention to float32’ or using `--no-half`…” ([GitHub](https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/6923 "[Bug]: A tensor with all NaNs was produced in Unet #6923"))

People get this on:

- AUTOMATIC1111
- ComfyUI
- Other UIs

even when they never touched the model files. It’s a **math / precision** issue:

- Too aggressive fp16 / bf16 / fp8 modes.
- Older or “sensitive” GPUs.
- Very heavy settings (high resolution, many LoRAs, etc.).

When you reinstall or copy ComfyUI, you often change:

- PyTorch version
- xFormers / attention kernels
- Default precision settings

Same `.safetensors` → different math engine → sometimes NaNs.

### Solution (plain steps)

For debugging:

1. Start with a **tiny test workflow** :

2. In ComfyUI settings / config, force safer precision:

3. If base-only works without NaNs:

4. If you get NaNs even with base-only:

* * *

## 4. Custom nodes / samplers causing NaNs or black images

Custom node packs can output NaNs or black images, even with good models.

Examples from ComfyUI GitHub / Reddit:

- Issue where **KSampler** started outputting NaNs in XL workflows, leading to black images. ([GitHub](https://github.com/comfyanonymous/ComfyUI/issues/9046 "Black images in XL and Nunchuka(Kontext Dev) caused by ..."))
- Z-Image turbo giving only black frames until a specific CUDNN toggle node was inserted (precision problem in the node’s code path). ([Reddit](https://www.reddit.com/r/comfyui/comments/1p9i300/getting_only_black_images_when_running_zimage/ "Getting only black images when running Z-Image turbo"))
- Qwen image workflows where generated images contain NaNs in the latent, not in the model weights. ([GitHub](https://github.com/comfyanonymous/ComfyUI/issues/9223 "Qwen image failed as the generated images containing ..."))

So a reinstall that pulls **new versions** of nodes (or Manager) can change behaviour even if models never moved.

### Solution (plain steps)

1. Temporarily disable custom nodes:

2. If NaNs disappear:

3. Once you know which pack causes trouble:

* * *

## 5. Portable version: why it’s a good idea for you

On Windows, the **Portable** version is just a folder you unzip and run. Official docs: “ComfyUI (portable) Windows” explain that you place `extra_model_paths.yaml` in the `ComfyUI` folder and run the `.bat` files. ([docs.comfy.org](https://docs.comfy.org/installation/comfyui_portable_windows "ComfyUI(portable) Windows"))

Advantages for your case:

1. **Self-contained environment**

2. **Easy to reset**

3. **Works perfectly with a central model folder**

So yes, for your use case:

- **Portable + one central models folder** is better than a heavyweight Desktop install that leaves hidden config all over AppData and is harder to reset cleanly.

* * *

## 6. Short checklist for you

Assuming file / disk are OK, on Windows:

- **Main causes** :

- **Practical solution** :

This way, reinstalling or copying ComfyUI does not touch your model files, and you isolate NaNs to configs, GPU settings, or nodes instead of constantly suspecting your backups.
