Home / Guide / Windows
Windows

AirLLM Windows Setup: Run Huge Language Models on a Windows PC

A practical AirLLM Windows guide covering Python, CUDA PyTorch, virtual environments, storage paths and the errors Windows users meet most often.

AirLLM Windows Setup: Run Huge Language Models on a Windows PC

Most tutorials for local language models assume Linux, yet a large share of people with capable graphics cards use Windows every day. The good news is that an AirLLM Windows setup is entirely achievable without dual-booting. AirLLM is pure Python on top of PyTorch, and PyTorch supports Windows with CUDA very well. This guide covers every step, explains the Windows-specific pitfalls and finishes with a tested script.

Why AirLLM suits Windows gaming PCs

Many Windows machines contain a mid-range NVIDIA card with 4 to 8 GB of VRAM and a fast NVMe drive. That combination is almost exactly what AirLLM was designed for. Instead of loading an entire 70B model into memory, AirLLM keeps the weights on disk as per-layer shards and moves one layer at a time into the GPU. The graphics card only needs room for a single layer plus a small set of activations, so a card that would normally struggle with a 7B model can process a 70B model, albeit slowly.

Step 1: check your hardware and driver

Open a terminal and run nvidia-smi. If the command prints a table with your GPU name, memory and driver version, the driver is installed correctly. Note the CUDA version shown in the top right; it tells you the highest CUDA runtime your driver supports. If the command is not found, install the latest Game Ready or Studio driver from NVIDIA before continuing.

  • GPU: NVIDIA with 4 GB VRAM minimum; 8 GB or more is noticeably more comfortable.
  • System RAM: 16 GB recommended.
  • Storage: NVMe SSD with at least 200 GB free for 70B-class models.

Step 2: install Python properly

Install Python 3.10 or 3.11 from python.org. During installation, tick the option that adds Python to PATH, and allow the installer to disable the path length limit when it offers to. The Windows launcher py lets you choose a specific version, which is useful if several are installed.

Step 3: create a virtual environment

mkdir C:\airllm
cd C:\airllm
py -3.11 -m venv venv
.\venv\Scripts\Activate.ps1

If PowerShell refuses to run the activation script, allow local scripts for your user with Set-ExecutionPolicy -Scope CurrentUser RemoteSigned and try again. The prompt should now begin with (venv).

Step 4: install CUDA-enabled PyTorch

This is the step where most AirLLM Windows installations go wrong. A plain pip install torch on Windows can install a CPU-only build. Always use the official index URL for the CUDA version your driver supports:

pip install torch --index-url https://download.pytorch.org/whl/cu124
python -c "import torch; print(torch.cuda.is_available(), torch.cuda.get_device_name(0))"

The second command must print True followed by your GPU's name. If it prints False, uninstall torch and reinstall from the correct index before going further.

Step 5: install AirLLM

pip install airllm
pip install bitsandbytes

The bitsandbytes package is only required for 4-bit and 8-bit compression. Recent versions publish Windows wheels, so it normally installs without fuss. If you prefer to work from source, download the ZIP from our download section, extract it and run pip install -e . inside the air_llm folder.

Step 6: choose a fast cache location

By default, Hugging Face stores models in your user profile on the C: drive. If C: is small or slow, redirect both the Hugging Face cache and the AirLLM shards:

setx HF_HOME D:\hf_cache

Then pass layer_shards_saving_path="D:/airllm_cache" when loading the model. Forward slashes work perfectly in Python on Windows and avoid escape-character confusion.

Step 7: run your first model

from airllm import AutoModel

model = AutoModel.from_pretrained(
    "Qwen/Qwen2.5-7B-Instruct",
    layer_shards_saving_path="D:/airllm_cache",
)
ids = model.tokenizer(["Name three uses for a local LLM."],
                      return_tensors="pt", truncation=True, max_length=128)
out = model.generate(ids["input_ids"].cuda(), max_new_tokens=40,
                     use_cache=True, return_dict_in_generate=True)
print(model.tokenizer.decode(out.sequences[0]))

Save the script as first_run.py and execute it with python first_run.py. The first execution downloads and splits the model; subsequent runs reuse the shards and start much sooner.

Windows-specific problems and solutions

Antivirus slows everything down

Real-time scanning can inspect every shard as AirLLM reads it, multiplying load times. Adding your cache folder to Microsoft Defender's exclusions often produces a dramatic speed improvement. Only exclude folders that contain files you downloaded from trusted sources.

Path too long errors

Hugging Face repository names create deep folder structures. Enable long paths in Windows or keep your cache close to the drive root, such as D:/hf.

Out-of-memory errors on 4 GB cards

Close browsers and games that hold GPU memory, reduce max_length, and try compression="4bit". Setting the environment variable PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True can also reduce fragmentation.

Sleep and power settings

Long generations can run for many minutes. Switch Windows to a high-performance power plan and prevent sleep while a job runs, or the process will pause midway.

Native Windows or WSL2?

Native Windows is simpler and performs well. WSL2 is worth considering when you rely on Linux-only tools or scripts. Under WSL2, keep model files inside the Linux file system rather than under /mnt/c, because cross-system file access is considerably slower, and AirLLM's speed depends heavily on disk reads.

Running AirLLM inside WSL2 step by step

If you prefer Linux tooling, Windows Subsystem for Linux offers a comfortable middle ground. Install WSL2 with the Ubuntu distribution from an administrator terminal using wsl --install. Current NVIDIA drivers for Windows already expose the GPU to WSL2, so you do not install a separate Linux driver. Inside Ubuntu, install Python and pip, create a virtual environment, install CUDA-enabled PyTorch and then AirLLM, exactly as you would on a Linux workstation.

The critical detail is file placement. Keep your models and shards inside the Linux home directory, for example ~/models, rather than on the Windows drives mounted under /mnt/c or /mnt/d. Cross-system file access in WSL2 is far slower than native access, and because AirLLM reads every layer for every token, that difference translates directly into much slower generation.

Monitoring your Windows system during a run

Task Manager's Performance tab is a useful companion. The disk graph should show sustained high read activity on the drive holding your shards; if it sits low while the GPU is idle, something else is limiting throughput, such as antivirus scanning or a slow drive. The GPU graph will typically show short bursts of activity as each layer is computed. Watching both together quickly reveals whether storage or computation is the bottleneck. For a more detailed view of GPU memory, keep nvidia-smi -l 1 running in a second terminal window.

TierExample setupWhat it handles well
Entry4 GB GTX or RTX card, SATA SSD, 16 GB RAM7B–14B models, patient 70B experiments
Comfortable8 GB RTX card, NVMe Gen3, 32 GB RAM70B models with compression
Enthusiast12–24 GB RTX card, NVMe Gen4, 64 GB RAMLarge MoE models and longer jobs

Notice that the storage column changes as much as the GPU column. For AirLLM, upgrading from a SATA SSD to a fast NVMe drive often delivers a larger improvement than upgrading the graphics card.

Keep a reproducible Windows baseline

Open a new PowerShell session and run the smallest generation example from the project folder. Use the same Python interpreter to install packages and run the script. If you normally start the program from an editor, compare the interpreter it selects with the one used in PowerShell. An editor can point to another environment even when both launch the same file. Record the interpreter path, Python version, AirLLM version and the GPU name from the first successful run.

Use an explicit directory for large model files and check the free space on that volume before starting preparation. A path on a secondary drive can still leave temporary files on the system drive if the download and output directories are configured independently. Check both drives during the first run so a full volume is easy to identify. If a path contains spaces, quote it consistently when passing it through PowerShell.

Verify CUDA with a small test before trying a large model. Then measure a short completion after the model files are prepared. Note whether the first run spends time downloading, splitting or generating. With that baseline recorded, you can compare what happens after a driver update or a move to a different drive. Keep the working environment while testing upgrades in a new one.

When a script works in PowerShell but fails under a scheduled task, check the working directory, selected interpreter and permissions for the account running it. A scheduled process can see a different environment and a differently mounted set of drives. Use absolute paths for the model and logs, then run one controlled job and inspect the result.

Frequently asked questions

Yes. AirLLM is a Python library, so it runs anywhere PyTorch with CUDA runs. Windows 10 and Windows 11 both work well when you install a CUDA-enabled PyTorch build that matches your NVIDIA driver.

No, native Windows works. WSL2 is a good alternative if you prefer Linux tooling or need a library that only ships Linux wheels, and it can access your NVIDIA GPU through the standard driver.

The standard workflow targets NVIDIA CUDA. AMD cards on Windows are not a supported path today, so most AMD users either run on CPU, which is very slow, or use Linux with ROCm and accept some experimentation.

Use the fastest NVMe drive you own and set layer_shards_saving_path to a short path such as D:/airllm_cache. Short paths also avoid the legacy 260-character limit that still causes errors on some Windows systems.

Conclusion

An AirLLM Windows installation comes down to three decisions made correctly: a CUDA-enabled PyTorch build, a virtual environment and a fast drive for layer shards. Get those right and a typical Windows gaming PC becomes a capable test bench for models far larger than its graphics card. When you are ready to tune performance, continue with our guide to AirLLM speed.