Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Fix psutil.cpu_count() potentially returning None in save.py
danielhanchen0b1dbefacb64
diff --git a/unsloth/save.py b/unsloth/save.pyindex 714df7682a8..071e032c536 100644--- a/unsloth/save.py+++ b/unsloth/save.py@@ -879,12 +879,12 @@ def install_llama_cpp_make_non_blocking():IS_CMAKE = Falseif check == 0:# Uses old MAKE- n_jobs = max(int(psutil.cpu_count() * 1.5), 1)+ n_jobs = max(int((psutil.cpu_count() or 1) * 1.5), 1)full_command = ["make", "all", "-j" + str(n_jobs), "-C", "llama.cpp"]IS_CMAKE = Falseelse:# Uses new CMAKE- n_jobs = max(int(psutil.cpu_count()), 1) # Use less CPUs since 1.5x faster+ n_jobs = max(int(psutil.cpu_count() or 1), 1) # Use less CPUs since 1.5x fastercheck = os.system(f"cmake llama.cpp -B llama.cpp/build -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=OFF {CURL_FLAG}")@@ -994,13 +994,13 @@ def install_llama_cpp_old(version = -10):# Try using MAKEcommands = ["make clean -C llama.cpp",- f"make all -j{psutil.cpu_count()*2} -C llama.cpp",+ f"make all -j{(psutil.cpu_count() or 1)*2} -C llama.cpp",]if try_execute(commands) == "CMAKE":# Instead use CMAKEcommands = [f"cmake llama.cpp -B llama.cpp/build -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=OFF {CURL_FLAG}",- f"cmake --build llama.cpp/build --config Release -j{psutil.cpu_count()*2} --clean-first --target {' '.join(LLAMA_CPP_TARGETS)}",+ f"cmake --build llama.cpp/build --config Release -j{(psutil.cpu_count() or 1)*2} --clean-first --target {' '.join(LLAMA_CPP_TARGETS)}","cp llama.cpp/build/bin/llama-* llama.cpp","rm -rf llama.cpp/build",]@@ -1040,14 +1040,14 @@ def install_llama_cpp_blocking(use_cuda = False):"make clean -C llama.cpp",# https://github.com/ggerganov/llama.cpp/issues/7062# Weirdly GPU conversion for GGUF breaks??- # f"{use_cuda} make all -j{psutil.cpu_count()*2} -C llama.cpp",- f"make all -j{psutil.cpu_count()*2} -C llama.cpp",+ # f"{use_cuda} make all -j{(psutil.cpu_count() or 1)*2} -C llama.cpp",+ f"make all -j{(psutil.cpu_count() or 1)*2} -C llama.cpp",]if try_execute(commands) == "CMAKE":# Instead use CMAKEcommands = [f"cmake llama.cpp -B llama.cpp/build -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=OFF {CURL_FLAG}",- f"cmake --build llama.cpp/build --config Release -j{psutil.cpu_count()*2} --clean-first --target {' '.join(LLAMA_CPP_TARGETS)}",+ f"cmake --build llama.cpp/build --config Release -j{(psutil.cpu_count() or 1)*2} --clean-first --target {' '.join(LLAMA_CPP_TARGETS)}","cp llama.cpp/build/bin/llama-* llama.cpp","rm -rf llama.cpp/build",]