Skip to content

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.

fix(trainer): import psutil to prevent NameError in _prepare_dataset (#3780)

Alkın Ünlü6180adda1bcd
diff --git a/unsloth/models/rl.py b/unsloth/models/rl.py
index 4ea36519d94..003a0e7f1b6 100644
--- a/unsloth/models/rl.py
+++ b/unsloth/models/rl.py
@@ -227,6 +227,7 @@ import numpy as np
from contextlib import nullcontext
from torch.nn import functional as F
import inspect
+import psutil
from transformers import DataCollatorForSeq2Seq, DataCollatorForLanguageModeling as TransformersDataCollatorForLanguageModeling
from transformers.training_args import ParallelMode
diff --git a/unsloth/tokenizer_utils.py b/unsloth/tokenizer_utils.py
index 99651643a8e..0136e3498ed 100644
--- a/unsloth/tokenizer_utils.py
+++ b/unsloth/tokenizer_utils.py
@@ -25,6 +25,7 @@ import collections
import numpy as np
import gc
import subprocess
+import psutil
from unsloth_zoo.tokenizer_utils import (
mean_of_trained_tokens,
diff --git a/unsloth/trainer.py b/unsloth/trainer.py
index c0b2dd03b60..0d98cff3051 100644
--- a/unsloth/trainer.py
+++ b/unsloth/trainer.py
@@ -14,6 +14,7 @@
import logging
import os
+import psutil
import warnings
from dataclasses import dataclass, field
from typing import Optional