Segmentation fault: 11
vlad43210 opened this issue ยท 9 comments
Hi, I just tried out sentence-transformers for the first time, and it gives a segmentation fault when importing:
>>> from sentence_transformers import SentenceTransformer
Segmentation fault: 11
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
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
- python3.10
- torch==2.1.0
- torchvision==0.16.0
- sentence-transformers==2.2.2