Open vlad43210 opened 2 years ago
Segmentation fault appears to be some memory error connected to C. I would guess that pytorch is the problem.
Can you import pytorch and transformers?
I found the solution for my problem -- I installed sentence-transformers
via pip as directed but installed pandas
via conda as I am used to. This causes the segmentation fault, though I do not know why. Cleaning out my environment and installing pandas from pip solved the issue. I would sugggest a small note in the README that this package is currently not compatible with conda.
I had a similar issue on Mac and re-installing numpy solved it for me.
I encountered a similar issue when trying to install sentence-transformers 2.2.2 in a Python 10 environment. The installation process failed with the segmentation fault
error message. After some troubleshooting, I found a solution that worked for me.
I downgraded my Python installation from version 10 to version 8, and then I was able to install sentence-transformers 2.2.2
without any issues. It seems that there is some incompatibility between sentence-transformers
and Python 10
.
If you're facing a similar issue, I suggest trying this solution. Of course, downgrading your Python installation may not be ideal if you're using other packages that require Python 10.
I got the segmenrtation fault with torch 2.1.0
, sentence_transformers; 2.2.2
and Python 3.9.2
Stack trace
Segmentation fault
root@9d5239199a96:/app# /usr/local/lib/python3.9/multiprocessing/resource_tracker.py:216: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown
warnings.warn('resource_tracker: There appear to be %d '
@nreimers this happens with Python 3.8.12
as well. I was using docker python:3.8.12-slim-bullseye
root@266ab0ebff1c:/app# python -c "import sentence_transformers; print(sentence_transformers.__version__)"
2.2.2
from sentence_transformers import SentenceTransformer
sentences = ["This is an example sentence", "Each sentence is converted"]
model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
embeddings = model.encode(sentences)
print(embeddings)
more details:
Downloading (…)e9125/.gitattributes: 100%|█| 1.18k/1.18k [00:00<00:00, 93
Downloading (…)_Pooling/config.json: 100%|█| 190/190 [00:00<00:00, 14.7kB
Downloading (…)7e55de9125/README.md: 100%|█| 10.6k/10.6k [00:00<00:00, 6.
Downloading (…)55de9125/config.json: 100%|█| 612/612 [00:00<00:00, 204kB/
Downloading (…)ce_transformers.json: 100%|█| 116/116 [00:00<00:00, 104kB/
Downloading (…)125/data_config.json: 100%|█| 39.3k/39.3k [00:00<00:00, 42
Downloading pytorch_model.bin: 100%|█| 90.9M/90.9M [00:24<00:00, 3.64MB/s
Downloading (…)nce_bert_config.json: 100%|███████████████████████████████████████████████████████████████████████████████| 53.0/53.0 [00:00<00:00, 9.56kB/s]
Downloading (…)cial_tokens_map.json: 100%|█████████████████████████████████████████████████████████████████████████████████| 112/112 [00:00<00:00, 18.3kB/s]
Downloading (…)e9125/tokenizer.json: 100%|███████████████████████████████████████████████████████████████████████████████| 466k/466k [00:00<00:00, 1.39MB/s]
Downloading (…)okenizer_config.json: 100%|██████████████████████████████████████████████████████████████████████████████████| 350/350 [00:00<00:00, 280kB/s]
Downloading (…)9125/train_script.py: 100%|█████████████████████████████████████████████████████████████████████████████| 13.2k/13.2k [00:00<00:00, 3.60MB/s]
Downloading (…)7e55de9125/vocab.txt: 100%|███████████████████████████████████████████████████████████████████████████████| 232k/232k [00:00<00:00, 1.00MB/s]
Downloading (…)5de9125/modules.json: 100%|██████████████████████████████████████████████████████████████████████████████████| 349/349 [00:00<00:00, 331kB/s]
Segmentation fault
[UPDATE]
Got the same issue with Python 3.10.13
Segmentation fault
root@a9ece55a69cc:/app# /usr/local/lib/python3.10/multiprocessing/resource_tracker.py:224: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown
warnings.warn('resource_tracker: There appear to be %d '
Encountered the same issue on Python 3.11 & 3.12 on Intel macOS.
I encountered similar issues. it got fixed by chaging the versions to python=3.10.0, torch=2.0.1, torchvision=0.15.2, sentence_transformer=2.2.2
In addition to @karthick1729 's suggestion i found the following downgrades also solved the issue
Hi, I just tried out sentence-transformers for the first time, and it gives a segmentation fault when importing:
This is on Python 3.8.12, I tried both
pip install -U sentence-transformers
and install from source. I have torch 1-.10.0 installed in this environment. I'd really appreciate any help you might be able to provide!Thank you,
Vlad