Stop Wasting Days on Environment Setup: How I Supercharged My Local LLM Training with uv and Unsloth
1. The "Secret Sauce" of Speed
Let’s be real: environment management in Python usually feels like dragging a boulder uphill. If you’ve ever spent four hours debugging CUDA version mismatches just to fine-tune a Llama-3, you know the pain.
Recently, I switched my workflow to the ultimate "Speed Combo": uv + Unsloth.
- uv is the Rust-based package manager that makes pip look like a dial-up modem. It’s blazingly fast and actually handles dependencies logically.
- Unsloth is the undisputed king of local fine-tuning. It’s 2x faster and uses 70% less memory than standard methods.
Putting them together isn't just a technical choice; it’s a lifestyle upgrade. I went from "debugging my environment" to "actually training models" in under 5 minutes. Here’s how I did it.
2. Pre-game: Ubuntu Prep
Before we touch the Python side, your Ubuntu box needs the basics. Don't skip the NVIDIA drivers—that’s the most common "it’s not working" culprit.
Make sure you have:
- NVIDIA Drivers (Obviously. Check with nvidia-smi).
- CUDA Toolkit (12.1 or higher recommended).
Basic Build Tools:
sudo apt update && sudo apt install -y git build-essential3. The Lightning-Fast Setup: Install uv
Forget manual Python installations or slow-as-molasses Conda. I used the one-liner from the Astral team to get uv running:
curl -LsSf https://astral.sh/uv/install.sh | shThe installation is so fast you’ll think it failed. It didn't. It's just that good.
4. The "Zero-Headache" Virtual Env
Here is my first big "pro-tip": Use Python 3.12.
I’ve tried 3.10 and 3.11, but 3.12 with uv has been the sweet spot for avoiding dependency hell. It’s cleaner, faster, and the compatibility is finally there.
uv venv --python=3.12
source .venv/bin/activateBy forcing 3.12, I’ve bypassed 90% of the "package not found" or "wheel failed to build" errors that plague the 3.9/3.10 era.
5. Installing Unsloth (And Avoiding the "Flash-Attn" Trap)
Now, here is where most people mess up. They start trying to manually compile flash-attn from source, or they follow three different outdated tutorials.
My advice? Don’t overthink it.
The Unsloth team has done an incredible job making the library "just work." You don't need to be a kernel engineer to get this running. Just use uv pip to grab the core stack:
uv pip install unsloth vllmThe Flash-Attention Warning:
Seriously, stop trying to manually install flash_attn unless you have a very specific reason. I’ve seen people spend two days trying to fix a flash_attn build error, while I’ve already finished training three models. uv and the modern Unsloth builds handle the heavy lifting. If it works, it works. Don't go looking for trouble!
Final Thoughts
Training LLMs locally shouldn't feel like a chore. By combining the raw speed of uv with the memory efficiency of Unsloth, I’ve turned my local workstation into a powerhouse. I spend less time staring at progress bars for installations and more time staring at loss curves.