OpenNMT / OpenNMT/CTranslate2

Importing `numpy` after `ctranslate2` causes segfault

Open
#1,181 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
4.7k
Forks
536
Avg merge
12h 12m
Merged PRs (30d)
4

Description

On my computer (MacBook Pro 14", 2021 with M1 Pro, 16GB RAM, Ventura 13.3.1), this code causes python to segfault:

import ctranslate2
import numpy as np

The fix is the following:

import numpy as np
import ctranslate2

I know that this usually doesn't happen, but on my machine it does.

I have the following packages installed (using pip) (in a conda environment):

Package            Version
------------------ -----------
accelerate         0.18.0
aiohttp            3.8.4
aiosignal          1.3.1
async-timeout      4.0.2
attrs              22.2.0
bandit             1.7.5
certifi            2022.12.7
charset-normalizer 3.1.0
contourpy          1.0.7
ctranslate2        3.12.0
cycler             0.11.0
filelock           3.10.7
fonttools          4.39.3
frozenlist         1.3.3
gitdb              4.0.10
GitPython          3.1.31
huggingface-hub    0.13.3
idna               3.4
kiwisolver         1.4.4
markdown-it-py     2.2.0
matplotlib         3.7.1
mdurl              0.1.2
multidict          6.0.4
numpy              1.24.2
openai             0.27.2
packaging          23.0
pbr                5.11.1
peft               0.3.0.dev0
Pillow             9.5.0
pip                23.0.1
psutil             5.9.4
Pygments           2.14.0
pyparsing          3.0.9
python-dateutil    2.8.2
PyYAML             6.0
regex              2023.3.23
requests           2.28.2
rich               13.3.3
sentencepiece      0.1.98
setuptools         67.6.1
six                1.16.0
smmap              5.0.0
stevedore          5.0.0
tokenizers         0.13.2
torch              1.13.1
tqdm               4.65.0
transformers       4.28.0.dev0
typing_extensions  4.5.0
urllib3            1.26.15
wheel              0.40.0
yarl               1.8.2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is identified in the report. Start by reproducing both import orders on the stated M1 Pro, macOS Ventura, Python, NumPy 1.24.2, and CTranslate2 3.12.0 environment; done means importing ctranslate2 before numpy no longer causes a segmentation fault.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.