pythonpytorchhuggingface-transformerstensorrtaccelerate

ImportError: Using the `Trainer` with `PyTorch` requires `accelerate`


I wrote a code to train a NER model before few months and it was working well. However, the same code now gives me this error:

ImportError: Using the `Trainer` with `PyTorch` requires `accelerate`: Run `pip install --upgrade accelerate`

I tried to install accelerate by following the instruction here however it is not running, this is the output when I tried to run accelerate:

2023-05-15 07:28:08.310904: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT

Copy-and-paste the text below in your GitHub issue

- `Accelerate` version: 0.19.0
- Platform: Linux-5.15.107+-x86_64-with-glibc2.31
- Python version: 3.10.11
- Numpy version: 1.22.4
- PyTorch version (GPU?): 2.0.0+cu118 (True)
- System RAM: 12.68 GB
- GPU type: Tesla T4
- `Accelerate` default config:
    - compute_environment: LOCAL_MACHINE
    - distributed_type: NO
    - mixed_precision: fp16
    - use_cpu: False
    - num_processes: 1
    - machine_rank: 0
    - num_machines: 1
    - rdzv_backend: static
    - same_network: False
    - main_training_function: main
    - downcast_bf16: False
    - tpu_use_cluster: False
    - tpu_use_sudo: False

I also installed TensorRT but this didn't solve the issue.

Here is my complete code for training.


Solution

  • Either installing !pip install accelerate -U and then restarting the runtime, or downgrading the PyTorch to 1.3.1 version should work.

    ! pip install torch==1.13.1