Skip to content

RuntimeError: Failed to import transformers.generation.utils #115

@VictorLeeICT

Description

@VictorLeeICT

I followed the install step and run :
PYTHONPATH=. python llava/eval/model_vqa.py
--conv-mode mistral_instruct
--model-path microsoft/llava-med-v1.5-mistral-7b
--question-file data/eval/llava_med_eval_qa50_qa.jsonl
--image-folder data/images
--answers-file /path/to/answer-file.jsonl
--temperature 0.0

but got following error:
/home/liqian/App/anaconda3/envs/llava-med/lib/python3.10/site-packages/bitsandbytes/cuda_setup/main.py:166: UserWarning: /home/liqian/App/anaconda3/envs/llava-med did not contain ['libcudart.so', 'libcudart.so.11.0', 'libcudart.so.12.0'] as expected! Searching further paths...
warn(msg)
The following directories listed in your path were found to be non-existent: {PosixPath('/home/liqian/.vscode-server/extensions/ms-python.debugpy-2025.4.1/.noConfigDebugAdapterEndpoints/endpoint-68b22c9801588a3d.txt')}
CUDA_SETUP: WARNING! libcudart.so not found in any environmental path. Searching in backup paths...
DEBUG: Possible options found for libcudart.so: {PosixPath('/usr/local/cuda/lib64/libcudart.so')}
CUDA SETUP: PyTorch settings found: CUDA_VERSION=124, Highest Compute Capability: 8.6.
CUDA SETUP: To manually override the PyTorch CUDA version please see:https://github.com/TimDettmers/bitsandbytes/blob/main/how_to_use_nonpytorch_cuda.md
CUDA SETUP: Required library version not found: libbitsandbytes_cuda124.so. Maybe you need to compile it from source?
CUDA SETUP: Defaulting to libbitsandbytes_cpu.so...

================================================ERROR=====================================
CUDA SETUP: CUDA detection failed! Possible reasons:

  1. You need to manually override the PyTorch CUDA version. Please see: "https://github.com/TimDettmers/bitsandbytes/blob/main/how_to_use_nonpytorch_cuda.md
  2. CUDA driver not installed
  3. CUDA not installed
  4. You have multiple conflicting CUDA libraries
  5. Required library not pre-compiled for this bitsandbytes release!
    CUDA SETUP: If you compiled from source, try again with make CUDA_VERSION=DETECTED_CUDA_VERSION for example, make CUDA_VERSION=113.
    CUDA SETUP: The CUDA version for the compile might depend on your conda install. Inspect CUDA version via conda list | grep cuda.
    ================================================================================

CUDA SETUP: Something unexpected happened. Please compile from source:
git clone https://github.com/TimDettmers/bitsandbytes.git
cd bitsandbytes
CUDA_VERSION=124
python setup.py install
CUDA SETUP: Setup Failed!
Traceback (most recent call last):
File "/home/liqian/App/anaconda3/envs/llava-med/lib/python3.10/site-packages/transformers/utils/import_utils.py", line 1382, in _get_module
return importlib.import_module("." + module_name, self.name)
File "/home/liqian/App/anaconda3/envs/llava-med/lib/python3.10/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1050, in _gcd_import
File "", line 1027, in _find_and_load
File "", line 1006, in _find_and_load_unlocked
File "", line 688, in _load_unlocked
File "", line 883, in exec_module
File "", line 241, in _call_with_frames_removed
File "/home/liqian/App/anaconda3/envs/llava-med/lib/python3.10/site-packages/transformers/generation/utils.py", line 85, in
from accelerate.hooks import AlignDevicesHook, add_hook_to_module
File "/home/liqian/App/anaconda3/envs/llava-med/lib/python3.10/site-packages/accelerate/init.py", line 3, in
from .accelerator import Accelerator
File "/home/liqian/App/anaconda3/envs/llava-med/lib/python3.10/site-packages/accelerate/accelerator.py", line 35, in
from .checkpointing import load_accelerator_state, load_custom_state, save_accelerator_state, save_custom_state
File "/home/liqian/App/anaconda3/envs/llava-med/lib/python3.10/site-packages/accelerate/checkpointing.py", line 24, in
from .utils import (
File "/home/liqian/App/anaconda3/envs/llava-med/lib/python3.10/site-packages/accelerate/utils/init.py", line 131, in
from .bnb import has_4bit_bnb_layers, load_and_quantize_model
File "/home/liqian/App/anaconda3/envs/llava-med/lib/python3.10/site-packages/accelerate/utils/bnb.py", line 42, in
import bitsandbytes as bnb
File "/home/liqian/App/anaconda3/envs/llava-med/lib/python3.10/site-packages/bitsandbytes/init.py", line 6, in
from . import cuda_setup, utils, research
File "/home/liqian/App/anaconda3/envs/llava-med/lib/python3.10/site-packages/bitsandbytes/research/init.py", line 1, in
from . import nn
File "/home/liqian/App/anaconda3/envs/llava-med/lib/python3.10/site-packages/bitsandbytes/research/nn/init.py", line 1, in
from .modules import LinearFP8Mixed, LinearFP8Global
File "/home/liqian/App/anaconda3/envs/llava-med/lib/python3.10/site-packages/bitsandbytes/research/nn/modules.py", line 8, in
from bitsandbytes.optim import GlobalOptimManager
File "/home/liqian/App/anaconda3/envs/llava-med/lib/python3.10/site-packages/bitsandbytes/optim/init.py", line 6, in
from bitsandbytes.cextension import COMPILED_WITH_CUDA
File "/home/liqian/App/anaconda3/envs/llava-med/lib/python3.10/site-packages/bitsandbytes/cextension.py", line 20, in
raise RuntimeError('''
RuntimeError:
CUDA Setup failed despite GPU being available. Please run the following command to get more information:

    python -m bitsandbytes

    Inspect the output of the command and see if you can locate CUDA libraries. You might need to add them
    to your LD_LIBRARY_PATH. If you suspect a bug, please take the information from python -m bitsandbytes
    and open an issue at: https://github.com/TimDettmers/bitsandbytes/issues

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/liqian/App/anaconda3/envs/llava-med/lib/python3.10/site-packages/transformers/utils/import_utils.py", line 1382, in _get_module
return importlib.import_module("." + module_name, self.name)
File "/home/liqian/App/anaconda3/envs/llava-med/lib/python3.10/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1050, in _gcd_import
File "", line 1027, in _find_and_load
File "", line 1006, in _find_and_load_unlocked
File "", line 688, in _load_unlocked
File "", line 883, in exec_module
File "", line 241, in _call_with_frames_removed
File "/home/liqian/App/anaconda3/envs/llava-med/lib/python3.10/site-packages/transformers/models/mistral/modeling_mistral.py", line 36, in
from ...modeling_utils import PreTrainedModel
File "/home/liqian/App/anaconda3/envs/llava-med/lib/python3.10/site-packages/transformers/modeling_utils.py", line 42, in
from .generation import GenerationConfig, GenerationMixin
File "", line 1075, in _handle_fromlist
File "/home/liqian/App/anaconda3/envs/llava-med/lib/python3.10/site-packages/transformers/utils/import_utils.py", line 1372, in getattr
module = self._get_module(self._class_to_module[name])
File "/home/liqian/App/anaconda3/envs/llava-med/lib/python3.10/site-packages/transformers/utils/import_utils.py", line 1384, in _get_module
raise RuntimeError(
RuntimeError: Failed to import transformers.generation.utils because of the following error (look up to see its traceback):

    CUDA Setup failed despite GPU being available. Please run the following command to get more information:

    python -m bitsandbytes

    Inspect the output of the command and see if you can locate CUDA libraries. You might need to add them
    to your LD_LIBRARY_PATH. If you suspect a bug, please take the information from python -m bitsandbytes
    and open an issue at: https://github.com/TimDettmers/bitsandbytes/issues

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/liqian/Code/LLaVA-Med/llava/eval/model_vqa.py", line 10, in
from llava.model.builder import load_pretrained_model
File "/home/liqian/Code/LLaVA-Med/llava/model/init.py", line 1, in
from .language_model.llava_mistral import LlavaMistralForCausalLM, LlavaMistralConfig
File "/home/liqian/Code/LLaVA-Med/llava/model/language_model/llava_mistral.py", line 6, in
from transformers import AutoConfig, AutoModelForCausalLM,
File "", line 1075, in _handle_fromlist
File "/home/liqian/App/anaconda3/envs/llava-med/lib/python3.10/site-packages/transformers/utils/import_utils.py", line 1373, in getattr
value = getattr(module, name)
File "/home/liqian/App/anaconda3/envs/llava-med/lib/python3.10/site-packages/transformers/utils/import_utils.py", line 1372, in getattr
module = self._get_module(self._class_to_module[name])
File "/home/liqian/App/anaconda3/envs/llava-med/lib/python3.10/site-packages/transformers/utils/import_utils.py", line 1384, in _get_module
raise RuntimeError(
RuntimeError: Failed to import transformers.models.mistral.modeling_mistral 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):

    CUDA Setup failed despite GPU being available. Please run the following command to get more information:

    python -m bitsandbytes

    Inspect the output of the command and see if you can locate CUDA libraries. You might need to add them
    to your LD_LIBRARY_PATH. If you suspect a bug, please take the information from python -m bitsandbytes
    and open an issue at: https://github.com/TimDettmers/bitsandbytes/issues

my cuda version is 12.5.Did I miss something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions