Skip to content

Bug in importing transformers modules #288

@ly01325

Description

@ly01325

Describe the bug

Can not import many transformers module, which are used in several tasks
Image

Image
and other module as well

Steps/Code to reproduce bug

git clone the repo
bash docker/build.sh
the bugs are in the official docker image env

Expected behavior

System information

======================================================================

  • Container used (if applicable): ?
  • OS (e.g., Ubuntu 22.04, CentOS 7, Windows 10): Ubuntu 24.04.2 LTS
  • CPU architecture (x86_64, aarch64): x86_64
  • GPU name (e.g. H100, A100, L40S): NVIDIA RTX 6000D
  • GPU memory size: 83.6 GB
  • Number of GPUs: 2
  • Library versions (if applicable):
    • Python: 3.12.3
    • ModelOpt version or commit hash: 0.35.0
    • CUDA: 12.9
    • PyTorch: 2.8.0+cu128
    • Transformers: 4.56.1
      :1297: FutureWarning: The cuda.cuda module is deprecated and will be removed in a future release, please switch to use the cuda.bindings.driver module instead.
      :1297: FutureWarning: The cuda.cudart module is deprecated and will be removed in a future release, please switch to use the cuda.bindings.runtime module instead.
      [2025-09-05 07:35:20] INFO utils.py:148: Note: detected 128 virtual cores but NumExpr set to maximum of 64, check "NUMEXPR_MAX_THREADS" environment variable.
      [2025-09-05 07:35:20] INFO utils.py:151: Note: NumExpr detected 128 cores but "NUMEXPR_MAX_THREADS" not set, so enforcing safe limit of 16.
      [2025-09-05 07:35:20] INFO utils.py:164: NumExpr defaulting to 16 threads.
      [2025-09-05 07:35:20] INFO config.py:54: PyTorch version 2.8.0 available.
      [2025-09-05 07:35:20] INFO config.py:66: Polars version 1.25.2 available.
      /usr/local/lib/python3.12/dist-packages/modelopt/torch/utils/import_utils.py:32: UserWarning: Failed to import peft plugin due to: ImportError("cannot import name 'PreTrainedModel' from 'transformers' (/usr/local/lib/python3.12/dist-packages/transformers/init.py)"). You may ignore this warning if you do not need this plugin.
      warnings.warn(
      /usr/local/lib/python3.12/dist-packages/modelopt/torch/utils/import_utils.py:32: UserWarning: Failed to import huggingface plugin due to: ImportError("cannot import name 'ModelOptHFTrainer' from 'modelopt.torch.opt.plugins' (/usr/local/lib/python3.12/dist-packages/modelopt/torch/opt/plugins/init.py)"). You may ignore this warning if you do not need this plugin.
      warnings.warn(
      /usr/local/lib/python3.12/dist-packages/modelopt/torch/trace/plugins/init.py:34: UserWarning: Failed to import transformers plugin due to: AttributeError("partially initialized module 'torchvision' has no attribute 'extension' (most likely due to a circular import)")
      _warnings.warn(f"Failed to import transformers plugin due to: {e!r}")
      /usr/local/lib/python3.12/dist-packages/modelopt/torch/utils/import_utils.py:32: UserWarning: Failed to import transformer engine plugin due to: AttributeError("module 'transformer_engine' has no attribute 'pytorch'"). You may ignore this warning if you do not need this plugin.
      warnings.warn(
      /usr/local/lib/python3.12/dist-packages/modelopt/torch/utils/import_utils.py:32: UserWarning: Failed to import transformers plugin due to: AttributeError("partially initialized module 'torchvision' has no attribute 'extension' (most likely due to a circular import)"). You may ignore this warning if you do not need this plugin.
      warnings.warn(
    • TensorRT-LLM: ?
    • ONNXRuntime: 1.22.0
    • TensorRT: 10.11.0.33
  • Any other details that may help: ?

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions