Traceback (most recent call last): File…
- User
Traceback (most recent call last): File "/usr/local/lib/python3.11/dist-packages/transformers/utils/import_utils.py", line 1967, in _get_module return importlib.import_module("." + module_name, self.name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1204, in _gcd_import File "", line 1176, in _find_and_load File "", line 1147, in _find_and_load_unlocked File "", line 690, in _load_unlocked File "", line 940, in exec_module File "", line 241, in _call_with_frames_removed File "/usr/local/lib/python3.11/dist-packages/transformers/generation/utils.py", line 30, in from transformers.generation.candidate_generator import AssistantVocabTranslatorCache File "/usr/local/lib/python3.11/dist-packages/transformers/generation/candidate_generator.py", line 27, in from sklearn.metrics import roc_curve File "/usr/local/lib/python3.11/dist-packages/sklearn/init.py", line 82, in from .base import clone File "/usr/local/lib/python3.11/dist-packages/sklearn/base.py", line 17, in from .utils import _IS_32BIT File "/usr/local/lib/python3.11/dist-packages/sklearn/utils/init.py", line 19, in from .murmurhash import murmurhash3_32 File "sklearn/utils/murmurhash.pyx", line 1, in init sklearn.utils.murmurhash ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/usr/local/lib/python3.11/dist-packages/transformers/utils/import_utils.py", line 1967, in _get_module return importlib.import_module("." + module_name, self.name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1204, in _gcd_import File "", line 1176, in _find_and_load File "", line 1147, in _find_and_load_unlocked File "", line 690, in _load_unlocked File "", line 940, in exec_module File "", line 241, in _call_with_frames_removed File "/usr/local/lib/python3.11/dist-packages/transformers/models/auto/modeling_auto.py", line 21, in from .auto_factory import ( File "/usr/local/lib/python3.11/dist-packages/transformers/models/auto/auto_factory.py", line 40, in from ...generation import GenerationMixin File "", line 1229, in _handle_fromlist File "/usr/local/lib/python3.11/dist-packages/transformers/utils/import_utils.py", line 1955, in getattr module = self._get_module(self._class_to_module[name]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/transformers/utils/import_utils.py", line 1969, in _get_module raise RuntimeError( RuntimeError: Failed to import transformers.generation.utils because of the following error (look up to see its traceback): numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/usr/local/bin/llamafactory-cli", line 5, in from llamafactory.cli import main File "/content/LLaMA-Factory/src/llamafactory/init.py", line 28, in from .extras.env import VERSION File "/content/LLaMA-Factory/src/llamafactory/extras/env.py", line 22, in import peft File "/usr/local/lib/python3.11/dist-packages/peft/init.py", line 17, in from .auto import ( File "/usr/local/lib/python3.11/dist-packages/peft/auto.py", line 21, in from transformers import ( File "", line 1229, in _handle_fromlist File "/usr/local/lib/python3.11/dist-packages/transformers/utils/import_utils.py", line 1956, in getattr value = getattr(module, name) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/transformers/utils/import_utils.py", line 1955, in getattr module = self._get_module(self._class_to_module[name]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/transformers/utils/import_utils.py", line 1969, in _get_module raise RuntimeError( RuntimeError: Failed to import transformers.models.auto.modeling_auto because of the following error (look up to see its traceback): Failed to import transformers.generation.utils because of the following error (look up to see its traceback): numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
- Assistant
This error
numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObjectusually indicates that there is a mismatch between the version of NumPy installed on your system and the binary modules (C extensions) compiled against an earlier or different version of NumPy. In your case, it appears when libraries such as scikit-learn (via its
murmurhashmodule) or parts of the Hugging Face Transformers library try to use NumPy.Below are several steps you can take to resolve the issue:
1. Upgrade NumPy
Make sure you have the latest (or a compatible) version of NumPy installed. For example, run:
pip install --upgrade numpyAfter upgrading, check its version in Python:
import numpy as np print(np.__version__)
2. Reinstall Dependent Packages
Some libraries (like scikit-learn or other C-extensions) may have been built against an earlier version of NumPy. To ensure they’re recompiled against your current NumPy version, reinstall them. For example:
pip uninstall scikit-learn -y pip install scikit-learnIf you’re using other libraries with C extensions (for example, if using libraries like
murmurhashdirectly), consider reinstalling them in a similar fashion.
3. Clear Build Caches
If you installed any packages from source or via wheels that might be cached, you might want to clear pip’s cache or force a rebuild:
pip install --no-cache-dir --force-reinstall scikit-learnand similarly for other affected packages like transformers or peft.
4. Check for Conflicting Environments
If you’re working in a virtual environment or using multiple Python installations, ensure that:
- You’re installing and upgrading packages in the correct environment.
- There are no leftover installations from a previous environment causing conflicts.
Using a virtual environment (e.g., via
python -m venv envor conda environments) often helps isolate package dependencies.
5. Pin Specific Versions
Occasionally, certain combinations of package versions are known to work together. If the above steps do not help, you might try downgrading NumPy or another package to a version recommended by the library’s documentation. For example, if a particular version of scikit-learn or transformers is known to work with your application, pin the versions in your
requirements.txt:numpy==1.21.6 scikit-learn==1.0.2 transformers==4.26.0Then reinstall using:
pip install -r requirements.txt --force-reinstall
Summary
The error is not directly from your code but arises from binary incompatibility between NumPy and one or more dependent libraries. By upgrading NumPy, reinstalling libraries with native extensions (like scikit-learn), and ensuring your environment is clean, you can usually resolve this issue.
Feel free to ask for more help if you run into further issues!
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.