Closed seema-AIML closed 1 year ago
Hi @seema-AIML
Could you post the full trace log, please. Thank you in advance.
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("bigscience/bloom-560m") def tokenize_function(examples): return tokenizer(examples["text"], padding="max_length", truncation=True) tokenized_datasets = dataset.map(tokenize_function, batched=True)
from transformers import AutoModelForSequenceClassification model = AutoModelForSequenceClassification.from_pretrained("bigscience/bloom-560m", num_labels=5)
from builtins import object from transformers import TrainingArguments training_args = TrainingArguments(output_dir="test_trainer")
While creating TrainingArguments getting below error
AttributeError Traceback (most recent call last) ~\Anaconda3\lib\site-packages\transformers\utils\import_utils.py in _get_module(self, module_name) 1125 try: -> 1126 return importlib.import_module("." + module_name, self.name) 1127 except Exception as e:
~\Anaconda3\lib\importlib__init__.py in import_module(name, package) 126 level += 1 --> 127 return _bootstrap._gcd_import(name[level:], package, level) 128
~\Anaconda3\lib\importlib_bootstrap.py in _gcd_import(name, package, level)
~\Anaconda3\lib\importlib_bootstrap.py in _find_andload(name, import)
~\Anaconda3\lib\importlib_bootstrap.py in _find_and_loadunlocked(name, import)
~\Anaconda3\lib\importlib_bootstrap.py in _load_unlocked(spec)
~\Anaconda3\lib\importlib_bootstrap_external.py in exec_module(self, module)
~\Anaconda3\lib\importlib_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)
~\Anaconda3\lib\site-packages\transformers\training_args.py in
~\Anaconda3\lib\site-packages\transformers\trainer_utils.py in
~\Anaconda3\lib\site-packages\tensorflow__init__.py in
~\Anaconda3\lib\site-packages\tensorflow\python__init__.py in
~\Anaconda3\lib\site-packages\tensorflow\python\data__init__.py in
~\Anaconda3\lib\site-packages\tensorflow\python\data\experimental__init__.py in
~\Anaconda3\lib\site-packages\tensorflow\python\data\experimental\service__init__.py in
~\Anaconda3\lib\site-packages\tensorflow\python\data\experimental\ops\data_service_ops.py in
~\Anaconda3\lib\site-packages\tensorflow\python\data\experimental\ops\compression_ops.py in
~\Anaconda3\lib\site-packages\tensorflow\python\data\util\structure.py in
~\Anaconda3\lib\site-packages\tensorflow\python\data\util\nest.py in
~\Anaconda3\lib\site-packages\tensorflow\python\framework\sparse_tensor.py in
~\Anaconda3\lib\site-packages\tensorflow\python\framework\constant_op.py in
~\Anaconda3\lib\site-packages\tensorflow\python\eager\execute.py in
~\Anaconda3\lib\site-packages\tensorflow\python\framework\dtypes.py in
~\Anaconda3\lib\site-packages\numpy__init.py in getattr(attr) 304 if attr in former_attrs: --> 305 raise AttributeError(former_attrs__[attr]) 306
AttributeError: module 'numpy' has no attribute 'object'.
np.object
was a deprecated alias for the builtin object
. To avoid this error in existing code, use object
by itself. Doing this will not modify any behavior and is safe.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
The above exception was the direct cause of the following exception:
RuntimeError Traceback (most recent call last)
The error occurs in tensorflow file.
~\Anaconda3\lib\site-packages\tensorflow\python\framework\dtypes.py in
584 types_pb2.DT_STRING:
--> 585 np.object,
If you don't need tensorflow, the quick way to check is to uninstall tensorflow and see if the issue is resolved.
You can also try to create a new virtual environment, and install as pip install transformers[torch]
.
created new a new virtual environment, and installed transformers[torch]. Still getting same error. I have not installed tensorflow in new virtual environment. when tried to uninstall tensorflow getting warning as WARNING: Skipping tensorflow as it is not installed.
Please provide the new full error log (the one that is run within the new environment).
AttributeError Traceback (most recent call last) ~\Anaconda3\lib\site-packages\transformers\utils\import_utils.py in _get_module(self, module_name) 1125 try: -> 1126 return importlib.import_module("." + module_name, self.name) 1127 except Exception as e:
~\Anaconda3\lib\importlib__init__.py in import_module(name, package) 126 level += 1 --> 127 return _bootstrap._gcd_import(name[level:], package, level) 128
~\Anaconda3\lib\importlib_bootstrap.py in _gcd_import(name, package, level)
~\Anaconda3\lib\importlib_bootstrap.py in _find_andload(name, import)
~\Anaconda3\lib\importlib_bootstrap.py in _find_and_loadunlocked(name, import)
~\Anaconda3\lib\importlib_bootstrap.py in _load_unlocked(spec)
~\Anaconda3\lib\importlib_bootstrap_external.py in exec_module(self, module)
~\Anaconda3\lib\importlib_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)
~\Anaconda3\lib\site-packages\transformers\training_args.py in
~\Anaconda3\lib\site-packages\transformers\trainer_utils.py in
~\Anaconda3\lib\site-packages\tensorflow__init__.py in
~\Anaconda3\lib\site-packages\tensorflow\python__init__.py in
~\Anaconda3\lib\site-packages\tensorflow\python\data__init__.py in
~\Anaconda3\lib\site-packages\tensorflow\python\data\experimental__init__.py in
~\Anaconda3\lib\site-packages\tensorflow\python\data\experimental\service__init__.py in
~\Anaconda3\lib\site-packages\tensorflow\python\data\experimental\ops\data_service_ops.py in
~\Anaconda3\lib\site-packages\tensorflow\python\data\experimental\ops\compression_ops.py in
~\Anaconda3\lib\site-packages\tensorflow\python\data\util\structure.py in
~\Anaconda3\lib\site-packages\tensorflow\python\data\util\nest.py in
~\Anaconda3\lib\site-packages\tensorflow\python\framework\sparse_tensor.py in
~\Anaconda3\lib\site-packages\tensorflow\python\framework\constant_op.py in
~\Anaconda3\lib\site-packages\tensorflow\python\eager\execute.py in
~\Anaconda3\lib\site-packages\tensorflow\python\framework\dtypes.py in
~\Anaconda3\lib\site-packages\numpy__init.py in getattr(attr) 304 if attr in former_attrs: --> 305 raise AttributeError(former_attrs__[attr]) 306
AttributeError: module 'numpy' has no attribute 'object'.
np.object
was a deprecated alias for the builtin object
. To avoid this error in existing code, use object
by itself. Doing this will not modify any behavior and is safe.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
The above exception was the direct cause of the following exception:
RuntimeError Traceback (most recent call last)
The error still shows tensorflow
is in your environment.
Could you show us the results of transformers-cli env
, pip show tensorflow
and pip show tensorflow-cpu
result of transformers-cli env
transformers
version: 4.30.2(hface) (base) D:>pip show tensorflow WARNING: Package(s) not found: tensorflow
(hface) (base) D:>pip show tensorflow-cpu WARNING: Package(s) not found: tensorflow-cpu
Hmm. The TF detection logic is in the following block.
You env. might still have something listed in
You can either check each of them and uninstall if they appear. Otherwise much easier, you can try to set the env. varialbe USE_TF
to False
, either by set USE_TF=0
or export USE_TF=0
I have set USE_TF = 0
%env USE_TF=0 from transformers import AutoTokenizer, BartForConditionalGeneration, Trainer, TrainingArguments model = BartForConditionalGeneration.from_pretrained("facebook/bart-base") training_args = TrainingArguments( output_dir='./results', # output directory num_train_epochs=3, # total number of training epochs per_device_train_batch_size=16, # batch size per device during training per_device_eval_batch_size=64, # batch size for evaluation warmup_steps=500, # number of warmup steps for learning rate scheduler weight_decay=0.01, # strength of weight decay logging_dir='./logs', # directory for storing logs logging_steps=10, )
trainer = Trainer(
model=model,
args=training_args,
train_dataset=train_dataset,
eval_dataset=val_dataset
)
trainer.train()
AttributeError Traceback (most recent call last)
Try to set report_to="none"
in training_args = TrainingArguments
. Your environment has mlflow
installed which might use some deprecated numpy
code. Or you can upgrade your mflow
versions.
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.
Please note that issues that do not follow the contributing guidelines are likely to be ignored.
System Info
falcon-7b-instruct(url)
Who can help?
No response
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
from transformers import pipeline
sequences = pipeline( "Write a poem about Valencia.", max_length=200, do_sample=True, top_k=10, num_return_sequences=1, eos_token_id=tokenizer.eos_token_id, ) for seq in sequences: print(f"Result: {seq['generated_text']}")
Expected behavior
Hi,
while running transformers API models on local machine facing issue of, Failed to import transformers.pipelines because of the following error (look up to see its traceback): module 'numpy' has no attribute 'object'.
np.object
was a deprecated alias for the builtinobject
. How to fix this?