Gnuradio and cuda with gr-cuda

Hello,
I’m using gnuradio in jetson nano and would like to give a try to the gpu acceleration with cuda.

The people of deepwavedigital made a component for gnuradio for enable the cuda capabilities to just put your code inside:

The component is made for python 2.7 so gnuradio 3.8 is not possible and have to install gnuradio 3.7.11 but luckily is the version available via sudo apt-install gnuradio.

installing the component like always in gnuradio but not possible to run the example, get this syntax error:

Traceback (most recent call last):
File “/home/juli/gnuradio/gr-cuda/test/top_block.py”, line 17, in
import cuda
File “/usr/local/lib/python2.7/dist-packages/cuda/init.py”, line 34, in
from gpu_kernel import gpu_kernel
File “/usr/local/lib/python2.7/dist-packages/cuda/gpu_kernel.py”, line 25, in
import pycuda.compiler
File “/home/juli/.local/lib/python2.7/site-packages/pycuda/compiler.py”, line 3, in
from pytools import memoize
File “/home/juli/.local/lib/python2.7/site-packages/pytools/init.py”, line 249
slots: List[str] =
^
SyntaxError: invalid syntax

Also from repository it says the pycuda version used is 9.0 but in jetson nano only from version 10 is available.

¿any ideas?.

Thanks.

Hi,

pyCUDA is a python wrapping different from the CUDA library.
Have you installed it first?

$ pip install pycuda --user

Thanks.

yes, pycuda was installed, but still got errors when importing the cuda library.

as pointed in github library the problem could be with version compatibility since the library use an older version of pycuda but after installed the version proposed from repository:

pip install pycuda==2019.1.2 pytools==2020.1

I still got some syntax errors if I run:

sudo python2 divide_by_two.py

File “divide_by_two.py”, line 31, in
import cuda
File “/usr/local/lib/python2.7/dist-packages/cuda/init.py”, line 34, in
from gpu_kernel import gpu_kernel
File “/usr/local/lib/python2.7/dist-packages/cuda/gpu_kernel.py”, line 27, in
import cupy as cp
File “/home/juli/.local/lib/python2.7/site-packages/cupy/init.py”, line 47, in
import cupyx as _cupyx
File “/home/juli/.local/lib/python2.7/site-packages/cupyx/init.py”, line 11, in
from cupyx._ufunc_config import errstate # NOQA
File “/home/juli/.local/lib/python2.7/site-packages/cupyx/_ufunc_config.py”, line 52
def errstate(*, divide=None, over=None, under=None, invalid=None, linalg=None):
^
SyntaxError: invalid syntax

Also when running without sudo:

import cuda
Traceback (most recent call last):
File “”, line 1, in
File “/usr/local/lib/python2.7/dist-packages/cuda/init.py”, line 34, in
from gpu_kernel import gpu_kernel
File “/usr/local/lib/python2.7/dist-packages/cuda/gpu_kernel.py”, line 25, in
import pycuda.compiler
File “/home/juli/.local/lib/python2.7/site-packages/pycuda/compiler.py”, line 3, in
from pytools import memoize
File “/home/juli/.local/lib/python2.7/site-packages/pytools/init.py”, line 249
slots: List[str] =
^
SyntaxError: invalid syntax

Looking for this error I realize I have a mess of libraries and sudo missed paths:
env | grep PATH
LD_LIBRARY_PATH=/user/local/lib:/user/local/lib:/usr/local/cuda-10.2/lib64:
PYTHONPATH=/usr/local/lib/python3/dist-packages:usr/local/lib/python2.7/site-packages:/usr/local/lib/python3/dist-packages:usr/local/lib/python2.7/site-packages:
PATH=/home/juli/.local/bin:/home/juli/c4aarch64_installer/bin:/home/juli/c4aarch64_installer/condabin:/usr/local/cuda-10.2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
sudo env | grep PATH
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

I don’t know if this could be the problem but maybe I can start with a new installation from zero and see what happens.

Thanks!.

Hi,

We give it a try with JetPack 4.5 and pycuda can run successfully in our environment.
Here is the details:

$ pip install pycuda==2019.1.2 pytools==2020.1
$ python
Python 2.7.17 (default, Feb 27 2021, 15:10:58) 
[GCC 7.5.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pycuda.autoinit
>>> import pycuda.driver as cuda
>>> 

Not sure if any difference in “import cuda”.
But we use “import pycuda.driver as cuda” for pycuda and it can work correctly.

Thanks.