huggingface / optimum-neuron

Easy, fast and very cheap training and inference on AWS Trainium and Inferentia chips.
Apache License 2.0
207 stars 61 forks source link

ViT image classification example broken with error: cannot import name 'is_fairscale_available' from 'transformers.integrations' #480

Closed kct22aws closed 4 days ago

kct22aws commented 8 months ago

System Info

optimum                       1.16.2
optimum-neuron                0.0.13
transformers                  4.37.2
transformers-neuronx          0.8.268
accelerate                    0.23.0
aws-neuronx-runtime-discovery 2.9
libneuronxla                  0.5.538
neuronx-cc                    2.11.0.34+c5231f848
neuronx-distributed           0.5.0
neuronx-hwm                   2.11.0.2+e34678757
optimum-neuron                0.0.13
torch-neuronx                 1.13.1.1.12.0
torch-xla                     1.13.1+torchneuronc
transformers-neuronx          0.8.268
*Note: Neuron version is 2.16.1 public release

Who can help?

No response

Information

Tasks

Reproduction (minimal, reproducible, runnable)

  1. Launch Inf2.8xl EC2 with U22.04.
  2. Install Neuron SDK 2.16.1 and PT1.13 per instruction.
  3. Install public version transformers, accelerate, diffusers, scikit-learn, datasets, evaluate
  4. Run script found in this repo with the following command:
    torchrun --nproc_per_node 2 run_image_classification.py \
    --dataset_name food101 \
    --output_dir ./food101_output/ \
    --remove_unused_columns False \
    --do_train \
    --do_eval \
    --learning_rate 2e-5 \
    --num_train_epochs 1 \
    --per_device_train_batch_size 16 \
    --seed 100 \
    --overwrite_output_dir \
    --logging_steps 10
  5. Observe output:

    
    *****************************************
    Setting OMP_NUM_THREADS environment variable for each process to be 1 in default, to avoid your system being overloaded, please further tune the variable for optimal performance in your application as needed. 
    *****************************************
    Traceback (most recent call last):
    File "/home/ubuntu/aws_neuron_venv_pytorch/lib/python3.10/site-packages/transformers/utils/import_utils.py", line 1364, in _get_module
    Traceback (most recent call last):
    File "/home/ubuntu/aws_neuron_venv_pytorch/lib/python3.10/site-packages/transformers/utils/import_utils.py", line 1364, in _get_module
    return importlib.import_module("." + module_name, self.__name__)
    File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return importlib.import_module("." + module_name, self.__name__)
    File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)return _bootstrap._gcd_import(name[level:], package, level)
    
    File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
    File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
    File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
    File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
    File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
    File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
    File "<frozen importlib._bootstrap_external>", line 883, in exec_module
    File "<frozen importlib._bootstrap_external>", line 883, in exec_module
    File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
    File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
    File "/home/ubuntu/aws_neuron_venv_pytorch/lib/python3.10/site-packages/optimum/neuron/trainers.py", line 31, in <module>
    File "/home/ubuntu/aws_neuron_venv_pytorch/lib/python3.10/site-packages/optimum/neuron/trainers.py", line 31, in <module>
        from transformers.integrations import is_fairscale_availablefrom transformers.integrations import is_fairscale_available

ImportErrorImportError: : cannot import name 'is_fairscale_available' from 'transformers.integrations' (/home/ubuntu/aws_neuron_venv_pytorch/lib/python3.10/site-packages/transformers/integrations/init.py)cannot import name 'is_fairscale_available' from 'transformers.integrations' (/home/ubuntu/aws_neuron_venv_pytorch/lib/python3.10/site-packages/transformers/integrations/init.py)



### Expected behavior

Expected this sample script to run without issue.
philschmid commented 7 months ago

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Thank you!

github-actions[bot] commented 1 week ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 4 days ago

This issue was closed because it has been stalled for 5 days with no activity.