Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PermissionError occurs when calling Trainer.trainer using transformers #28716

Closed
2 of 4 tasks
Mickls opened this issue Jan 26, 2024 · 3 comments
Closed
2 of 4 tasks

PermissionError occurs when calling Trainer.trainer using transformers #28716

Mickls opened this issue Jan 26, 2024 · 3 comments

Comments

@Mickls
Copy link

Mickls commented Jan 26, 2024

System Info

  • transformers version: 4.37.1
  • Platform: Windows-10-10.0.22631-SP0
  • Python version: 3.10.13
  • Huggingface_hub version: 0.20.3
  • Safetensors version: 0.4.2
  • Accelerate version: 0.26.1
  • Accelerate config: not found
  • PyTorch version (GPU?): 2.1.0+cu121 (True)
  • Tensorflow version (GPU?): not installed (NA)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed
  • Using GPU in script?:
  • Using distributed or parallel set-up in script?:

Who can help?

@muellerzr @pacman100

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

The error code block comes from the official example https://huggingface.co/docs/transformers/tasks/sequence_classification
The following is the specific code

training_args = TrainingArguments(
    output_dir="my_awesome_model",
    learning_rate=2e-5,
    per_device_train_batch_size=16,
    per_device_eval_batch_size=16,
    num_train_epochs=2,
    weight_decay=0.01,
    evaluation_strategy="epoch",
    save_strategy="epoch",
    load_best_model_at_end=True,
    push_to_hub=False,
)

trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=tokenized_imdb["train"],
    eval_dataset=tokenized_imdb["test"],
    tokenizer=tokenizer,
    data_collator=data_collator,
    compute_metrics=compute_metrics,
)

trainer.train()

Expected behavior

In trainer.py:2418 line fd = os.open(output_dir, os.O_RDONLY), if the windows system tries to open a folder, a PermissionError exception will be triggered, so this piece of code will cause the train function to save the trained model to be interrupted.If possible, I hope you can be compatible with windows platform

@amyeroberts
Copy link
Collaborator

Hi @Mickls, thanks for raising this issue!

A fix was merged in #28637. Could you try installing transformers from source and see if this resolves the issue for you?

pip install git+https://github.com/huggingface/transformers

@Mickls
Copy link
Author

Mickls commented Jan 26, 2024

Hi @Mickls, thanks for raising this issue!

A fix was merged in #28637. Could you try installing transformers from source and see if this resolves the issue for you?

pip install git+https://github.com/huggingface/transformers

Yes it works fine now, thanks

Copy link

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.

@Mickls Mickls closed this as completed Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants