Skip to content

UnicodeDecodeError in unsloth_zoo/compiler.py when reading source files on Windows #2474

Closed

Description

@larcenous

Describe the bug
I used below link to install unsloth for window
https://docs.unsloth.ai/get-started/installing-+-updating/windows-installation

'unsloth-compiled-cache' is created after one run and unicoded decode error occurs when running again

  1. Environment Setup:

    • OS: window 10
    • Python Version: 3.10.16
    • Frameworks/Libraries: please paste output of pip freeze here
      • accelerate==1.6.0
        aiohappyeyeballs==2.6.1
        aiohttp==3.11.18
        aiosignal==1.3.2
        annotated-types==0.7.0
        anyio==4.9.0
        asgiref==3.8.1
        asttokens==3.0.0
        async-timeout==4.0.3
        attrs==23.2.0
        backoff==2.2.1
        bcrypt==4.3.0
        beautifulsoup4==4.13.4
        bitsandbytes==0.45.5
        boto3==1.34.158
        botocore==1.34.158
        bs4==0.0.2
        build==1.2.2.post1
        cachetools==5.5.2
        certifi==2024.8.30
        chardet==3.0.4
        charset-normalizer==2.1.1
        chroma-hnswlib==0.7.6
        chromadb==1.0.7
        click==8.1.8
        cloudpickle==3.1.1
        colorama==0.4.6
        coloredlogs==15.0.1
        comm==0.2.2
        copulas==0.11.0
        cragmm-search-pipeline==0.4.2
        ctgan==0.10.1
        cut-cross-entropy==25.1.1
        dataclasses-json==0.6.7
        datasets==3.5.1
        debugpy==1.8.14
        decorator==5.2.1
        deepecho==0.6.0
        Deprecated==1.2.18
        diffusers==0.33.1
        dill==0.3.8
        distro==1.9.0
        docstring_parser==0.16
        dotenv==0.9.9
        durationpy==0.9
        exceptiongroup==1.2.2
        executing==2.2.0
        Faker==26.3.0
        fastapi==0.115.9
        filelock==3.18.0
        flatbuffers==25.2.10
        frozendict==2.4.4
        frozenlist==1.6.0
        fsspec==2025.3.0
        google-auth==2.39.0
        googleapis-common-protos==1.70.0
        googletrans==4.0.0rc1
        graphviz==0.20.3
        greenlet==3.2.1
        grpcio==1.71.0
        h11==0.14.0
        h2==3.2.0
        hf-xet==1.1.0
        hf_transfer==0.1.9
        hstspreload==2024.3.1
        html5lib==1.1
        httpcore==1.0.5
        httptools==0.6.4
        httpx==0.27.2
        httpx-sse==0.4.0
        huggingface-hub==0.30.2
        humanfriendly==10.0
        idna==3.8
        importlib_metadata==8.6.1
        importlib_resources==6.5.2
        inquirerpy==0.3.4
        ipykernel==6.29.5
        ipython==8.36.0
        jedi==0.19.2
        Jinja2==3.1.6
        jiter==0.5.0
        jmespath==1.0.1
        joblib==1.5.0
        jsonpatch==1.33
        jsonpointer==3.0.0
        jsonschema==4.23.0
        jsonschema-specifications==2025.4.1
        jupyter_client==8.6.3
        jupyter_core==5.7.2
        kubernetes==32.0.1
        langchain==0.3.25
        langchain-community==0.3.23
        langchain-core==0.3.58
        langchain-experimental==0.3.4
        langchain-openai==0.2.1
        langchain-text-splitters==0.3.8
        langsmith==0.1.129
        lmdb==1.6.2
        loguru==0.7.3
        markdown-it-py==3.0.0
        MarkupSafe==3.0.2
        marshmallow==3.26.1
        matplotlib-inline==0.1.7
        mdurl==0.1.2
        mmh3==5.1.0
        mpmath==1.3.0
        msgspec==0.19.0
        multidict==6.4.3
        multiprocess==0.70.16
        mypy_extensions==1.1.0
        nest-asyncio==1.6.0
        networkx==3.4.2
        numpy==1.26.4
        oauthlib==3.2.2
        onnxruntime==1.21.1
        openai==1.50.2
        opentelemetry-api==1.32.1
        opentelemetry-exporter-otlp-proto-common==1.32.1
        opentelemetry-exporter-otlp-proto-grpc==1.32.1
        opentelemetry-instrumentation==0.53b1
        opentelemetry-instrumentation-asgi==0.53b1
        opentelemetry-instrumentation-fastapi==0.53b1
        opentelemetry-proto==1.32.1
        opentelemetry-sdk==1.32.1
        opentelemetry-semantic-conventions==0.53b1
        opentelemetry-util-http==0.53b1
        orjson==3.10.7
        outcome==1.3.0.post0
        overrides==7.7.0
        p_tqdm==1.4.2
        packaging==24.1
        pandas==2.2.3
        parmap==1.7.0
        parso==0.8.4
        pathos==0.3.2
        peft==0.15.2
        pfzy==0.3.4
        pillow==11.2.1
        platformdirs==4.2.2
        plotly==5.23.0
        posthog==4.0.1
        pox==0.3.6
        ppft==1.7.7
        prompt_toolkit==3.0.51
        propcache==0.3.1
        protobuf==3.20.3
        psutil==7.0.0
        pure_eval==0.2.3
        pyarrow==20.0.0
        pyasn1==0.6.1
        pyasn1_modules==0.4.2
        pydantic==2.11.4
        pydantic-settings==2.9.1
        pydantic_core==2.33.2
        Pygments==2.19.1
        PyPika==0.48.9
        pyproject_hooks==1.2.0
        pyreadline3==3.5.4
        python-dateutil==2.9.0.post0
        python-dotenv==1.1.0
        pytz==2025.2
        pywin32==310
        PyYAML==6.0.2
        pyzmq==26.4.0
        rdt==1.12.2
        referencing==0.36.2
        regex==2024.11.6
        requests==2.32.3
        requests-oauthlib==2.0.0
        rich==14.0.0
        rpds-py==0.24.0
        rsa==4.9.1
        s3transfer==0.10.2
        safetensors==0.5.3
        scikit-learn==1.6.1
        scipy==1.15.2
        sdmetrics==0.15.0
        sdv==1.15.0
        selenium==4.19.0
        sentence-transformers==4.1.0
        sentencepiece==0.2.0
        shellingham==1.5.4
        shtab==1.7.2
        six==1.17.0
        sniffio==1.3.1
        soupsieve==2.7
        SQLAlchemy==2.0.40
        stack-data==0.6.3
        starlette==0.45.3
        sympy==1.14.0
        tenacity==9.1.2
        threadpoolctl==3.6.0
        tiktoken==0.7.0
        tokenizers==0.21.1
        tomli==2.2.1
        torch==2.7.0+cu128
        torchaudio==2.7.0+cu128
        torchvision==0.22.0+cu128
        tornado==6.4.2
        tqdm==4.67.1
        traitlets==5.14.3
        transformers==4.51.3
        trio==0.25.0
        trio-websocket==0.11.1
        triton-windows==3.3.0.post19
        trl==0.15.2
        typeguard==4.4.2
        typer==0.15.3
        typing-inspect==0.9.0
        typing-inspection==0.4.0
        typing_extensions==4.13.2
        tyro==0.9.19
        tzdata==2025.2
        unsloth @ git+https://github.com/unslothai/unsloth.git@a2017aafec25795e54a72190dcc0662c3f337458
        unsloth_zoo==2025.4.4
        urllib3==2.2.2
        uvicorn==0.34.2
        watchfiles==1.0.5
        wcwidth==0.2.13
        websocket-client==1.8.0
        websockets==15.0.1
        win32_setctime==1.2.0
        wrapt==1.17.2
        wsproto==1.2.0
        xformers==0.0.30
        xxhash==3.5.0
        yarl==1.20.0
        zipp==3.21.0
    • colab / script - run on .py script
  2. Dataset Details:

    • Dataset Name:
    • Data Preprocessing Steps: [e.g., tokenization, formatting funcs, data collators, etc.]
  3. Model Details:

self.model, self.processor = FastVisionModel.from_pretrained(
            "unsloth/Llama-3.2-11B-Vision-Instruct-bnb-4bit",
            load_in_4bit = True, # Use 4bit to reduce memory use. False for 16bit LoRA.
            use_gradient_checkpointing = "unsloth", # True or "unsloth" for long context
        )
  1. Training Configuration:

    • Trainer Args: SFTConfig, GRPOConfig
  2. Reproduction Steps:

    • Minimal script to reproduce error
    • If using a colab, please provide the link to the notebook and describe any changes made.
  3. Expected Behavior:

  4. Actual Behavior:

Please restructure your imports with 'import unsloth' at the top of your file.
  from unsloth import FastVisionModel
🦥 Unsloth: Will patch your computer to enable 2x faster free finetuning.
🦥 Unsloth Zoo will now patch everything to make training faster!
Traceback (most recent call last):
  File "F:\work\meta-comprehensive-rag-benchmark-starter-kit\local_evaluation.py", line 8, in <module>
    from agents.user_config import UserAgent
  File "F:\work\meta-comprehensive-rag-benchmark-starter-kit\agents\user_config.py", line 4, in <module>
    from agents.CoT_agent import CoTAgent
  File "F:\work\meta-comprehensive-rag-benchmark-starter-kit\agents\CoT_agent.py", line 1, in <module>
    from unsloth import FastVisionModel
  File "D:\anaconda3\envs\mm_exp_env\lib\site-packages\unsloth\__init__.py", line 220, in <module>
    from .models import *
  File "D:\anaconda3\envs\mm_exp_env\lib\site-packages\unsloth\models\__init__.py", line 15, in <module>
    from .llama     import FastLlamaModel
  File "D:\anaconda3\envs\mm_exp_env\lib\site-packages\unsloth\models\llama.py", line 2758, in <module>
    PatchFastRL(FastLanguageModel = FastLlamaModel)
  File "D:\anaconda3\envs\mm_exp_env\lib\site-packages\unsloth\models\rl.py", line 742, in PatchFastRL
    patch_trl_rl_trainers()
  File "D:\anaconda3\envs\mm_exp_env\lib\site-packages\unsloth\models\rl.py", line 735, in patch_trl_rl_trainers
    _patch_trl_rl_trainers(trainer)
  File "D:\anaconda3\envs\mm_exp_env\lib\site-packages\unsloth\models\rl.py", line 555, in _patch_trl_rl_trainers
    created_module = create_new_function(
  File "D:\anaconda3\envs\mm_exp_env\lib\site-packages\unsloth_zoo\compiler.py", line 336, in create_new_function
    with open(function_location, "r") as f: file_source = f.read()
UnicodeDecodeError: 'cp949' codec can't decode byte 0xcf in position 3538: illegal multibyte sequence
  1. Additional notes:
    • Any additional information that might help us reproduce the bug.

Activity

  1. larcenous commented on May 4, 2025

    @larcenous
    Author

    solved using setx PYTHONIOENCODING utf-8 /M

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions