UChicago-Computational-Content-Analysis / Frequently-Asked-Questions

0 stars 0 forks source link

Troubleshooting version incompatibility of transformers #16

Open JunsolKim opened 2 years ago

JunsolKim commented 2 years ago

Hi all,

It seems that transformers returns the following issue if transformers version is incompatible with tensorflow or pytorch. Try to downgrade transformers to 3.1.0 if you encounter this error (pip install transformers==3.1.0).


RuntimeError Traceback (most recent call last) /var/folders/jj/0bctc_l95rs6_k0g9qqhb4w40000gn/T/ipykernel_18520/4005870990.py in 1 from transformers import pipeline ----> 2 nlp = pipeline("sentiment-analysis") 3 result = nlp("I hate you")[0] 4 print(f"label: {result['label']}, with score: {round(result['score'], 4)}") 5 result = nlp("I love you")[0]

~/opt/anaconda3/envs/content/lib/python3.7/site-packages/transformers/pipelines/init.py in pipeline(task, model, config, tokenizer, feature_extractor, framework, revision, use_fast, use_auth_token, model_kwargs, pipeline_class, kwargs) 546 revision=revision, 547 task=task, --> 548 model_kwargs, 549 ) 550

~/opt/anaconda3/envs/content/lib/python3.7/site-packages/transformers/pipelines/base.py in infer_framework_load_model(model, config, model_classes, task, framework, **model_kwargs) 177 if not is_tf_available() and not is_torch_available(): 178 raise RuntimeError( --> 179 "At least one of TensorFlow 2.0 or PyTorch should be installed. " 180 "To install TensorFlow 2.0, read the instructions at https://www.tensorflow.org/install/ " 181 "To install PyTorch, read the instructions at https://pytorch.org/."

RuntimeError: At least one of TensorFlow 2.0 or PyTorch should be installed. To install TensorFlow 2.0, read the instructions at https://www.tensorflow.org/install/ To install PyTorch, read the instructions at https://pytorch.org/.