Segmentation fault when importing pycuda drivers

Hello every one,
I am trying to import pycuda drivers but i get a segmentation fault.
When i tried to find the error using faulthandler i get this :

$ python3
Python 3.6.9 (default, Mar 10 2023, 16:46:00) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import faulthandler
>>> faulthandler.enable()
>>> from pycuda._driver import *
Fatal Python error: Segmentation fault

Current thread 0x0000007f98329010 (most recent call first):
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 35 in <module>
  File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 678 in exec_module
  File "<frozen importlib._bootstrap>", line 665 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 955 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 971 in _find_and_load
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24 in <module>
  File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 678 in exec_module
  File "<frozen importlib._bootstrap>", line 665 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 955 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 971 in _find_and_load
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 26 in <module>
  File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 678 in exec_module
  File "<frozen importlib._bootstrap>", line 665 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 955 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 971 in _find_and_load
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30 in <module>
  File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 678 in exec_module
  File "<frozen importlib._bootstrap>", line 665 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 955 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 971 in _find_and_load
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5 in <module>
  File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 678 in exec_module
  File "<frozen importlib._bootstrap>", line 665 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 955 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 971 in _find_and_load
  File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 941 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 971 in _find_and_load
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 72 in apport_excepthook
Segmentation fault (core dumped)



Environment
Nvidia card:Jetson AGX Xavier
TensorRT Version : 8.0.1.6
CUDA Version : 10.2.300
CUDNN Version : 8.2.1.32
Operating System + Version : Ubuntu 18.04

Any help please

to provide more details, I tried to debug with “gdb” and i get the following output:

$ gdb python3
GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "aarch64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from python3...(no debugging symbols found)...done.
(gdb) r -c "from pycuda._driver import *"
Starting program: /usr/bin/python3 -c "from pycuda._driver import *"
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x0000007fb76eba48 in ?? ()
(gdb) bt
#0  0x0000007fb76eba48 in ?? ()
#1  0x0000007fb74f807c in ?? ()
   from /usr/lib/aarch64-linux-gnu/libapt-pkg.so.5.0
#2  0x0000007fb74f8dec in pkgInitSystem(Configuration&, pkgSystem*&) ()
   from /usr/lib/aarch64-linux-gnu/libapt-pkg.so.5.0
#3  0x0000007fb7747364 in ?? ()
   from /usr/lib/python3/dist-packages/apt_pkg.cpython-36m-aarch64-linux-gnu.so
#4  0x00000000005bcd24 in _PyCFunction_FastCallDict ()
#5  0x000000000052ca48 in ?? ()
#6  0x0000000000531698 in _PyEval_EvalFrameDefault ()
#7  0x000000000052c0e0 in ?? ()
#8  0x000000000053a7a4 in ?? ()
#9  0x00000000005bd008 in PyCFunction_Call ()
#10 0x00000000005340b4 in _PyEval_EvalFrameDefault ()
#11 0x000000000052c0e0 in ?? ()
#12 0x000000000052c674 in ?? ()
#13 0x000000000052c8cc in ?? ()
#14 0x0000000000531698 in _PyEval_EvalFrameDefault ()
#15 0x000000000052a950 in ?? ()
#16 0x000000000052c8cc in ?? ()
#17 0x0000000000531698 in _PyEval_EvalFrameDefault ()
#18 0x000000000052a950 in ?? ()
#19 0x000000000052c8cc in ?? ()
#20 0x0000000000531698 in _PyEval_EvalFrameDefault ()
#21 0x000000000052a950 in ?? ()
#22 0x000000000052c8cc in ?? ()
#23 0x0000000000531698 in _PyEval_EvalFrameDefault ()
#24 0x000000000052a950 in ?? ()
#25 0x00000000006089f8 in _PyObject_FastCallDict ()
#26 0x0000000000609798 in _PyObject_CallMethodIdObjArgs ()
#27 0x0000000000429144 in ?? ()
#28 0x00000000005339b8 in _PyEval_EvalFrameDefault ()
---Type <return> to continue, or q <return> to quit---
````Preformatted text`

Hi,

This error is related to pycuda mechanism in initialization.
Could you try the below command?

import pycuda.autoinit
import pycuda.driver as cuda

Thanks.

Hi,
It throws Segmentation fault when i execute the first import (import pycuda.autoinit)
I think yes, it is related to pycuda mechanism in intialization. Can i try install pycuda from terminal or i should flash the card?
Thanks

Hi,

Usually, it works with pip3 install pycuda --user.

If the issue goes on, would you mind upgrading to the latest JetPack 5.1.1?
We have tested pyCUDA on it and it can work without error.

Thanks

I installed the version of pycuda 2021.1 with : pip3 install pycuda==2021.1and the problem is resolved.
Thank you

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.