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

Question/Bug: Trying to use sentence-transformers (v3.0.0) with Google Colab's TPU #2730

Closed
harisarang opened this issue Jun 7, 2024 · 3 comments

Comments

@harisarang
Copy link

harisarang commented Jun 7, 2024

I am trying to use sentence transformers for model retrieval fine-tuning use case. But I am not able to run it on Google Colab's TPUv2. My kernel is restarting if I am importing sentence_transformers itself.

Here is the snippet of the code

!pip install torch~=2.3.0 torch_xla[tpu]~=2.3.0 -f https://storage.googleapis.com/libtpu-releases/index.html
!pip install sentence-transformers
!pip install datasets
!pip install transformers[torch]
!pip install accelerate -U
from datasets import load_dataset, Dataset
from sentence_transformers import (
    SentenceTransformer,
    SentenceTransformerTrainer,
    SentenceTransformerTrainingArguments,
    SentenceTransformerModelCardData,
)
from sentence_transformers.losses import CosineSimilarityLoss, ContrastiveLoss, MultipleNegativesRankingLoss
from sentence_transformers.training_args import BatchSamplers
from sentence_transformers.evaluation import InformationRetrievalEvaluator

The import itself makes the kernel to restart,
ERROR: Unknown command line flag 'xla_latency_hiding_scheduler_rerun'
image

Am I doing something wrong here ?

Here, is the link to the notebook: Colab Notebook

P.S. v3.0.0 makes training a lot more easier a good feature/refactor of fine tuning from previous versions. Kudos to @tomaarsen and other contributors.

Thanks in advance

@tomaarsen
Copy link
Collaborator

Hello!

This looks quite similar to this issue: huggingface/transformers#28609 (comment)
Could you try pip uninstall tensorflow before running the Sentence Transformers related imports?

  • Tom Aarsen

@harisarang
Copy link
Author

Thanks a lot @tomaarsen. This worked

@tomaarsen
Copy link
Collaborator

Glad to hear it!

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