Closed tempaccountforissue closed 8 months ago
Have you tried using a debugger to find the cause of the crash?
It's more likely that this is a bug in Torch than in CPython.
@JelleZijlstra I've never used a debugger with the Python/C API. Are there any resources you know of that I could use for this?
Any C++ debugger should do.
Also details about how you add torch to your import path/how you install it would help in replicating the crash.
@ethanhs It's an embedded version of Python, so I followed this Stack Overflow post to get pip installed. Then I followed the instructions on PyTorch's website to install Torch.
I used the following configuration for installing PyTorch:
Do you need any other information?
Have you contacted PyTorch about this? Core devs don't typically debug issues like this, which involve third party code, unless it's pretty clear that it's indeed a Python bug and there is no way to narrow it down - those cases are rare, and this doesn't seem to be one of them.
@iritkatriel I created an issue on PyTorch's GitHub page around the same time I created this one. They have been (slowly) looking into it. I will update this issue if they find anything definitive.
Thanks. If they find reason to believe there is a bug in python then please create an issue with a clear bug report.
i got a similar issue. My embedded python with windows embeddable package crashes when importing numpy. Do you have any information for me ? how to use a c++ debugger in windows ?
Bug report
I'm trying to embed Python into a C++ based application using the Python/C API. If I don't include an embedded Python installation inside my projects folder, then the program uses my local Python install by default. Using the local install doesn't result in any errors and torch is able to import successfully. However, if I include a Windows embeddable package (64-bit) version of Python in my projects folder, then Python crashes after calling
PyImport_ImportModule("importsFile")
in my C++ file.Inside of
importsFile.py
I have the following code:If I comment out
import torch
, then the other modules are able to import without error. However, if I leaveimport torch
uncommented, then Python crashes.I'm not sure if this is a bug on Python's side or PyTorch's side. Python only seems to crash when importing torch specifically, but it also only crashes when calling
PyImport_ImportModule
. So, it seems to me like it could be on either end.Is this a known issue? How can I fix it?
Your environment
CPython versions tested on: Python 3.9.7 - Windows embeddable package (64-bit)
Operating system and architecture: Windows 10 64-bit