Skip to content

[Bug] [MultiGPU/DDP] TypeError: expected str, bytes or os.PathLike object, not NoneType #3722

Closed

Description

@ep5000
  1. Did you update? pip install --upgrade unsloth unsloth_zoo yes
  2. Colab or Kaggle or local / cloud local
  3. Number GPUs used, use nvidia-smi 2
  4. Which notebook? Please link! https://docs.unsloth.ai/basics/multi-gpu-training-with-unsloth/ddp
  5. Which Unsloth version, TRL version, transformers version, PyTorch version? PyTorch
  6. Which trainer? SFTTrainer, GRPOTrainer etc used Unsloth cli

I ran the following (using the instructions on the linked DDP fine-tuning tutorial) and encountered the resulting error (see the bash log below):

torchrun --nproc_per_node=2 unsloth-cli.py   --model_name=Qwen/Qwen3-8B   --dataset=yahma/alpaca-cleaned --save_model

W1211 01:23:30.336000 22744 torch/distributed/run.py:803] 
W1211 01:23:30.336000 22744 torch/distributed/run.py:803] *****************************************
W1211 01:23:30.336000 22744 torch/distributed/run.py:803] Setting OMP_NUM_THREADS environment variable for each process to be 1 in default, to avoid your system being overloaded, please further tune the variable for optimal performance in your application as needed. 
W1211 01:23:30.336000 22744 torch/distributed/run.py:803] *****************************************
🦥 Unsloth: Will patch your computer to enable 2x faster free finetuning.
🦥 Unsloth: Will patch your computer to enable 2x faster free finetuning.
🦥 Unsloth Zoo will now patch everything to make training faster!
🦥 Unsloth Zoo will now patch everything to make training faster!
Traceback (most recent call last):
  File "/home/my-user/development/unsloth2/unsloth/unsloth/lib/python3.12/site-packages/unsloth_zoo/compiler.py", line 672, in create_new_function
    new_module, old_path = import_module(compile_folder, name)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/my-user/development/unsloth2/unsloth/unsloth/lib/python3.12/site-packages/unsloth_zoo/compiler.py", line 668, in import_module
    raise e
  File "/home/my-user/development/unsloth2/unsloth/unsloth/lib/python3.12/site-packages/unsloth_zoo/compiler.py", line 663, in import_module
    new_module = importlib.import_module(name)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1324, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'UnslothBCOTrainer'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/my-user/development/unsloth2/unsloth/unsloth-cli.py", line 441, in <module>
    run(args)
  File "/home/my-user/development/unsloth2/unsloth/unsloth-cli.py", line 37, in run
    from unsloth import FastLanguageModel
  File "/home/my-user/development/unsloth2/unsloth/unsloth/__init__.py", line 257, in <module>
    from .models import *
  File "/home/my-user/development/unsloth2/unsloth/unsloth/models/__init__.py", line 15, in <module>
    from .llama import FastLlamaModel
  File "/home/my-user/development/unsloth2/unsloth/unsloth/models/llama.py", line 3400, in <module>
    PatchFastRL(FastLanguageModel = FastLlamaModel)
  File "/home/my-user/development/unsloth2/unsloth/unsloth/models/rl.py", line 1347, in PatchFastRL
    patch_trl_rl_trainers()
  File "/home/my-user/development/unsloth2/unsloth/unsloth/models/rl.py", line 1333, in patch_trl_rl_trainers
    _patch_trl_rl_trainers(trainer)
  File "/home/my-user/development/unsloth2/unsloth/unsloth/models/rl.py", line 1003, in _patch_trl_rl_trainers
    created_module = create_new_function(
                     ^^^^^^^^^^^^^^^^^^^^
  File "/home/my-user/development/unsloth2/unsloth/unsloth/lib/python3.12/site-packages/unsloth_zoo/compiler.py", line 678, in create_new_function
    function_location = os.path.join(compile_folder, f"{name}.py")
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen posixpath>", line 76, in join
TypeError: expected str, bytes or os.PathLike object, not NoneType
/home/my-user/development/unsloth2/unsloth/unsloth/models/rl_replacements.py:946: UserWarning: You are importing from 'trl.experimental'. APIs here are unstable and may change or be removed without notice. Silence this warning by setting environment variable TRL_EXPERIMENTAL_SILENCE=1.
  import trl.experimental.openenv.utils as openenv_utils
[unsloth_zoo.log|WARNING]Unsloth: Failed to import trl openenv: No module named 'trl.experimental.openenv'
W1211 01:23:34.640000 22744 torch/distributed/elastic/multiprocessing/api.py:908] Sending process 22782 closing signal SIGTERM
E1211 01:23:34.755000 22744 torch/distributed/elastic/multiprocessing/api.py:882] failed (exitcode: 1) local_rank: 1 (pid: 22783) of binary: /home/my-user/development/unsloth2/unsloth/unsloth/bin/python
Traceback (most recent call last):
  File "/home/my-user/development/unsloth2/unsloth/unsloth/bin/torchrun", line 7, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/my-user/development/unsloth2/unsloth/unsloth/lib/python3.12/site-packages/torch/distributed/elastic/multiprocessing/errors/__init__.py", line 357, in wrapper
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/home/my-user/development/unsloth2/unsloth/unsloth/lib/python3.12/site-packages/torch/distributed/run.py", line 936, in main
    run(args)
  File "/home/my-user/development/unsloth2/unsloth/unsloth/lib/python3.12/site-packages/torch/distributed/run.py", line 927, in run
    elastic_launch(
  File "/home/my-user/development/unsloth2/unsloth/unsloth/lib/python3.12/site-packages/torch/distributed/launcher/api.py", line 156, in __call__
    return launch_agent(self._config, self._entrypoint, list(args))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/my-user/development/unsloth2/unsloth/unsloth/lib/python3.12/site-packages/torch/distributed/launcher/api.py", line 293, in launch_agent
    raise ChildFailedError(
torch.distributed.elastic.multiprocessing.errors.ChildFailedError: 
============================================================
unsloth-cli.py FAILED
------------------------------------------------------------
Failures:
  <NO_OTHER_FAILURES>
------------------------------------------------------------
Root Cause (first observed failure):
[0]:
  time      : 2025-12-11_01:23:34
  host      : my-pc
  rank      : 1 (local_rank: 1)
  exitcode  : 1 (pid: 22783)
  error_file: <N/A>
  traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html
============================================================

Please advise how to rectify this. For additional info, here's my nvidia-smi output:

+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 575.51.03              Driver Version: 575.51.03      CUDA Version: 12.9     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce RTX 3090        Off |   00000000:01:00.0 Off |                  N/A |
| 40%   28C    P8             22W /  350W |      18MiB /  24576MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
|   1  NVIDIA GeForce RTX 3090        Off |   00000000:02:00.0 Off |                  N/A |
| 40%   26C    P8              7W /  350W |      18MiB /  24576MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
                                                                                         
+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|    0   N/A  N/A            6167      G   /usr/lib/xorg/Xorg                        4MiB |
|    1   N/A  N/A            6167      G   /usr/lib/xorg/Xorg                        4MiB |
+-----------------------------------------------------------------------------------------+

Activity

  1. vedantdere commented on Dec 12, 2025

    @vedantdere

    Hi @ep5000,

    I tried replicating the issue on my end. I tested it using the Qwen/Qwen3-0.6B model, and it’s working correctly for me.

    You can refer to the Colab notebook below for the exact setup and steps I followed:
    https://colab.research.google.com/drive/1zWVkbTQ5uRGzz9PrtcSERwNbnjZgiznd?usp=sharing

    Please let me know if I’m missing any specific configuration or if you’d like me to test another setup.

    Thanks!

  2. Datta0 commented on Dec 15, 2025

    @Datta0
    Contributor

    Hey @ep5000 , on DDP, there was a small issue that we fixed in the current codebase but perhaps haven't released it yet.
    I suggest you can either wait for the next pypi release of unsloth or if you don't mind trying, you can install from source using

    pip install git+https://github.com/unslothai/unsloth.git
    pip install git+https://github.com/unslothai/unsloth-zoo.git
    
  3. Datta0 commented on Dec 15, 2025

    @Datta0
    Contributor
  4. djsaunde commented on Dec 15, 2025

    @djsaunde
    Contributor

    @danielhanchen @Datta0 is correct, could we do an unsloth-zoo release so this fix is in the PyPI package?

  5. changed the title [-][Bug] DDP Fine-Tuning Fails: Failed to import trl openenv: No module named 'trl.experimental.openenv'[/-] [+][Bug] [MultiGPU/DDP] TypeError: expected str, bytes or os.PathLike object, not NoneType[/+] on Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions