Closed patriciogonzalezvivo closed 4 years ago
Hello Patricio, thanks for trying PyRadio! Does your computer have an NVidia Graphics card? If not, this might be the problem. Try changing the cuda
variable from True
to False
like the example below.
# Demodulator Settings
cuda = False
Hi @luigifreitas, thanks for the promptly replay. I do have an GTX Nvidia graphic card in my laptop set "OnDemand" mode. I try running the script with offload-glx python3 multi_mfm.py
, then turning cuda = False
but with no success.
...
# Tuner Settings:
Bandwidth: 9984000.0
Mean Frequency: 92700000.0
Offsets: [4800000.0, 2800000.0, -4800000.0, -1200000.0, 4200000.0]
Radios: 5
[INFO] Make connection: 'LimeSDR Mini [USB 3.0] 1D3CCBDE66D3FA'
[INFO] Reference clock 40.00 MHz
[INFO] Device name: LimeSDR-Mini
[INFO] Reference: 40 MHz
[INFO] LMS7002M calibration values caching Disable
[INFO] Selected RX path: LNAW
[INFO] Rx calibration finished
Traceback (most recent call last):
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/SoapySDR.py", line 1314, in <lambda>
File "multi_mfm.py", line 61, in process
tuner.load(que.get())
File "/usr/local/lib/python3.7/dist-packages/radio/tools/tuner/__init__.py", line 49, in load
__setattr__ = lambda self, name, value: _swig_setattr(self, StreamResult, name, value)
AttributeError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "multi_mfm.py", line 98, in <module>
self.b = self.xs.fft(self.xp.array(buff))
AttributeError: module 'scipy.signal' has no attribute 'fft'
sdr.readStream(rx, [buff[(i*sdr_buff):]], sdr_buff, timeoutUs=int(1e9))
File "/usr/local/lib/python3.7/dist-packages/SoapySDR.py", line 2045, in readStream
return self.readStream__(stream, ptrs, numElems, flags, timeoutUs)
File "/usr/local/lib/python3.7/dist-packages/SoapySDR.py", line 2024, in readStream__
return _SoapySDR.Device_readStream__(self, stream, buffs, numElems, flags, timeoutUs)
SystemError: <built-in function Device_readStream__> returned a result with an error set
libusb: warning [libusb_exit] application left some devices open
I was doing some research on CuSignal and one mayor difference on my setup is that I'm not using conda
. I have install all under the system's Python 3.7.5 (including other software like limesdr, SoapySDR, gnuradio, Osmocom, etc).
I would prefer not to switch to conda
, Do you think that's the issue?
Thanks for replying! I think I found the problem. This particular script multi_mfm.py
requires a slightly modified cuSignal library that can be found here. You can replace the current installation by running the following commands:
$ pip uninstall -y cusignal
$ git clone https://github.com/luigifreitas/cusignal cusignal-fork
$ cd cusignal-fork
$ git checkout compatibility
$ sudo python3 setup.py install
Thanks again for the fast reply!
I follow your instructions:
copying build/lib/cusignal/test/__init__.py -> build/bdist.linux-x86_64/egg/cusignal/test
copying build/lib/cusignal/test/test_wavelets.py -> build/bdist.linux-x86_64/egg/cusignal/test
copying build/lib/cusignal/test/test_signaltools.py -> build/bdist.linux-x86_64/egg/cusignal/test
copying build/lib/cusignal/test/test_windows.py -> build/bdist.linux-x86_64/egg/cusignal/test
copying build/lib/cusignal/test/utils.py -> build/bdist.linux-x86_64/egg/cusignal/test
copying build/lib/cusignal/test/test_spectral.py -> build/bdist.linux-x86_64/egg/cusignal/test
copying build/lib/cusignal/test/test_waveforms.py -> build/bdist.linux-x86_64/egg/cusignal/test
copying build/lib/cusignal/fir_filter_design.py -> build/bdist.linux-x86_64/egg/cusignal
creating build/bdist.linux-x86_64/egg/cusignal/cupy_helper
copying build/lib/cusignal/cupy_helper/__init__.py -> build/bdist.linux-x86_64/egg/cusignal/cupy_helper
copying build/lib/cusignal/cupy_helper/polynomial.py -> build/bdist.linux-x86_64/egg/cusignal/cupy_helper
copying build/lib/cusignal/cupy_helper/linalg_extended.py -> build/bdist.linux-x86_64/egg/cusignal/cupy_helper
copying build/lib/cusignal/_upfirdn.py -> build/bdist.linux-x86_64/egg/cusignal
copying build/lib/cusignal/fftpack_helper.py -> build/bdist.linux-x86_64/egg/cusignal
copying build/lib/cusignal/waveforms.py -> build/bdist.linux-x86_64/egg/cusignal
copying build/lib/cusignal/bsplines.py -> build/bdist.linux-x86_64/egg/cusignal
copying build/lib/cusignal/wavelets.py -> build/bdist.linux-x86_64/egg/cusignal
byte-compiling build/bdist.linux-x86_64/egg/cusignal/_peak_finding.py to _peak_finding.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/cusignal/_arraytools.py to _arraytools.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/cusignal/__init__.py to __init__.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/cusignal/spectral.py to spectral.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/cusignal/signaltools.py to signaltools.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/cusignal/_spectral.py to _spectral.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/cusignal/_signaltools.py to _signaltools.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/cusignal/windows.py to windows.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/cusignal/test/__init__.py to __init__.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/cusignal/test/test_wavelets.py to test_wavelets.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/cusignal/test/test_signaltools.py to test_signaltools.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/cusignal/test/test_windows.py to test_windows.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/cusignal/test/utils.py to utils.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/cusignal/test/test_spectral.py to test_spectral.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/cusignal/test/test_waveforms.py to test_waveforms.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/cusignal/fir_filter_design.py to fir_filter_design.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/cusignal/cupy_helper/__init__.py to __init__.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/cusignal/cupy_helper/polynomial.py to polynomial.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/cusignal/cupy_helper/linalg_extended.py to linalg_extended.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/cusignal/_upfirdn.py to _upfirdn.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/cusignal/fftpack_helper.py to fftpack_helper.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/cusignal/waveforms.py to waveforms.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/cusignal/bsplines.py to bsplines.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/cusignal/wavelets.py to wavelets.cpython-37.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying cusignal.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying cusignal.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying cusignal.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying cusignal.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating 'dist/cusignal-0.1-py3.7.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing cusignal-0.1-py3.7.egg
Copying cusignal-0.1-py3.7.egg to /usr/local/lib/python3.7/dist-packages
Adding cusignal 0.1 to easy-install.pth file
Installed /usr/local/lib/python3.7/dist-packages/cusignal-0.1-py3.7.egg
Processing dependencies for cusignal==0.1
Finished processing dependencies for cusignal==0.1
pytho3 multi_mfm.py
but saddly this error appear again.And then run `# Tuner Settings:
Bandwidth: 9984000.0
Mean Frequency: 92700000.0
Offsets: [4800000.0, 2800000.0, -4800000.0, -1200000.0, 4200000.0]
Radios: 5
[INFO] Make connection: 'LimeSDR Mini [USB 3.0] 1D3CCBDE66D3FA'
[INFO] Reference clock 40.00 MHz
[INFO] Device name: LimeSDR-Mini
[INFO] Reference: 40 MHz
[INFO] LMS7002M calibration values caching Disable
[INFO] Selected RX path: LNAW
[INFO] Rx calibration finished
Traceback (most recent call last):
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/SoapySDR.py", line 1314, in <lambda>
File "multi_mfm.py", line 61, in process
__setattr__ = lambda self, name, value: _swig_setattr(self, StreamResult, name, value)
AttributeError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "multi_mfm.py", line 98, in <module>
sdr.readStream(rx, [buff[(i*sdr_buff):]], sdr_buff, timeoutUs=int(1e9))
tuner.load(que.get())
File "/usr/local/lib/python3.7/dist-packages/SoapySDR.py", line 2045, in readStream
File "/usr/local/lib/python3.7/dist-packages/radio/tools/tuner/__init__.py", line 49, in load
self.b = self.xs.fft(self.xp.array(buff))
return self.readStream__(stream, ptrs, numElems, flags, timeoutUs)
AttributeError: module 'cusignal' has no attribute 'fft'
File "/usr/local/lib/python3.7/dist-packages/SoapySDR.py", line 2024, in readStream__
return _SoapySDR.Device_readStream__(self, stream, buffs, numElems, flags, timeoutUs)
SystemError: <built-in function Device_readStream__> returned a result with an error set
libusb: warning [libusb_exit] application left some devices open
Any ideas of what I might be doing wrong? Thanks for you patience
The package could not be completely uninstalled. This happens to me sometimes. To prevent that, I first uninstall the package and check if the script errors out before I attempt to install the update package.
$ pip uninstall -y cusignal
$ python3 multi_mfm.py ### this should error out
$ git clone https://github.com/luigifreitas/cusignal cusignal-fork
$ cd cusignal-fork
$ sudo python3 setup.py install
I uninstall
run multi_mfm.py
I get an error of not fininding cusignal
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Traceback (most recent call last):
File "multi_mfm.py", line 30, in <module>
tuner = Tuner(radios, cuda=cuda)
File "/usr/local/lib/python3.7/dist-packages/radio/tools/tuner/__init__.py", line 8, in __init__
self.load_modules(cuda)
File "/usr/local/lib/python3.7/dist-packages/radio/tools/tuner/__init__.py", line 38, in load_modules
self.xs = importlib.import_module('cusignal')
File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'cusignal'
Reclone and install
$ git clone https://github.com/luigifreitas/cusignal cusignal-fork
$ cd cusignal-fork
$ sudo python3 setup.py install
Run multi_mfm.py again and I get the same error:
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
# Tuner Settings:
Bandwidth: 9984000.0
Mean Frequency: 92700000.0
Offsets: [4800000.0, 2800000.0, -4800000.0, -1200000.0, 4200000.0]
Radios: 5
[INFO] Make connection: 'LimeSDR Mini [USB 3.0] 1D3CCBDE66D3FA'
[INFO] Reference clock 40.00 MHz
[INFO] Device name: LimeSDR-Mini
[INFO] Reference: 40 MHz
[INFO] LMS7002M calibration values caching Disable
[INFO] Selected RX path: LNAW
[INFO] Rx calibration finished
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/SoapySDR.py", line 1314, in <lambda>
__setattr__ = lambda self, name, value: _swig_setattr(self, StreamResult, name, value)
AttributeError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "multi_mfm.py", line 98, in
: (
Same error if I run it with cuda=False
[INFO] Rx calibration finished
Traceback (most recent call last):
File "multi_mfm.py", line 61, in process
tuner.load(que.get())
File "/usr/local/lib/python3.7/dist-packages/radio/tools/tuner/__init__.py", line 49, in load
self.b = self.xs.fft(self.xp.array(buff))
AttributeError: module 'scipy.signal' has no attribute 'fft'
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/SoapySDR.py", line 1314, in <lambda>
__setattr__ = lambda self, name, value: _swig_setattr(self, StreamResult, name, value)
AttributeError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "multi_mfm.py", line 98, in <module>
sdr.readStream(rx, [buff[(i*sdr_buff):]], sdr_buff, timeoutUs=int(1e9))
File "/usr/local/lib/python3.7/dist-packages/SoapySDR.py", line 2045, in readStream
return self.readStream__(stream, ptrs, numElems, flags, timeoutUs)
File "/usr/local/lib/python3.7/dist-packages/SoapySDR.py", line 2024, in readStream__
return _SoapySDR.Device_readStream__(self, stream, buffs, numElems, flags, timeoutUs)
SystemError: <built-in function Device_readStream__> returned a result with an error set
libusb: warning [libusb_exit] application left some devices open
Sorry, I forgot that the customization is on a different branch. The installation code should be this one.
$ pip uninstall -y cusignal
$ git clone https://github.com/luigifreitas/cusignal cusignal-fork
$ cd cusignal-fork
$ git checkout compatibility
$ sudo python3 setup.py install
Yay! That worked out! Thanks!
Now i have another issue but seams to be caused by numba
: /
[INFO] Device name: LimeSDR-Mini
[INFO] Reference: 40 MHz
[INFO] LMS7002M calibration values caching Disable
[INFO] Selected RX path: LNAW
[INFO] Rx calibration finished
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/numba/cuda/cudadrv/nvvm.py", line 111, in __new__
inst.driver = open_cudalib('nvvm', ccc=True)
File "/usr/local/lib/python3.7/dist-packages/numba/cuda/cudadrv/libs.py", line 47, in open_cudalib
raise OSError('library %s not found' % lib)
OSError: library nvvm not found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "multi_mfm.py", line 64, in process
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/SoapySDR.py", line 1314, in <lambda>
L = demod.run(tuner.run(i))
File "/usr/local/lib/python3.7/dist-packages/radio/analog/mfm.py", line 60, in run
LPR = self.xs.resample_poly(b, 1, self.dec, window='hamm')
File "/usr/local/lib/python3.7/dist-packages/cusignal-0.1-py3.7.egg/cusignal/signaltools.py", line 1555, in resample_poly
__setattr__ = lambda self, name, value: _swig_setattr(self, StreamResult, name, value)
numba.cuda.cudadrv.error.NvvmSupportError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/cusignal-0.1-py3.7.egg/cusignal/_upfirdn.py", line 239, in upfirdn
File "multi_mfm.py", line 98, in <module>
File "/usr/local/lib/python3.7/dist-packages/cusignal-0.1-py3.7.egg/cusignal/_upfirdn.py", line 143, in apply_filter
sdr.readStream(rx, [buff[(i*sdr_buff):]], sdr_buff, timeoutUs=int(1e9))
File "/usr/local/lib/python3.7/dist-packages/SoapySDR.py", line 2045, in readStream
return self.readStream__(stream, ptrs, numElems, flags, timeoutUs)
File "/usr/local/lib/python3.7/dist-packages/SoapySDR.py", line 2024, in readStream__
File "/usr/local/lib/python3.7/dist-packages/numba/cuda/compiler.py", line 798, in __call__
return _SoapySDR.Device_readStream__(self, stream, buffs, numElems, flags, timeoutUs)
kernel = self.specialize(*args)
SystemError: <built-in function Device_readStream__> returned a result with an error set
File "/usr/local/lib/python3.7/dist-packages/numba/cuda/compiler.py", line 809, in specialize
kernel = self.compile(argtypes)
File "/usr/local/lib/python3.7/dist-packages/numba/cuda/compiler.py", line 828, in compile
kernel.bind()
File "/usr/local/lib/python3.7/dist-packages/numba/cuda/compiler.py", line 542, in bind
self._func.get()
File "/usr/local/lib/python3.7/dist-packages/numba/cuda/compiler.py", line 420, in get
ptx = self.ptx.get()
File "/usr/local/lib/python3.7/dist-packages/numba/cuda/compiler.py", line 391, in get
**self._extra_options)
Fatal Python error: could not acquire lock for <_io.BufferedWriter name='<stderr>'> at interpreter shutdown, possibly due to daemon threads
Thread 0x00007f2a7dfff700 (most recent call first):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 152 in apport_excepthook
Current thread 0x00007f2b14d49740 (most recent call first):
[1] 11561 abort sudo python3 multi_mfm.py
Any idea?
Ok... got some progress.
numba
numba
from source following thismulti_mfm.py
again and got this:[~/Desktop/PyRadio]$ sudo python3 multi_mfm.py [master]
ALSA lib pcm.c:2564:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2564:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2564:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:869:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:869:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:869:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:869:(find_matching_chmap) Found no matching channel map
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused
ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
# Tuner Settings:
Bandwidth: 9984000.0
Mean Frequency: 92700000.0
Offsets: [4800000.0, 2800000.0, -4800000.0, -1200000.0, 4200000.0]
Radios: 5
[INFO] Make connection: 'LimeSDR Mini [USB 3.0] 1D3CCBDE66D3FA'
[INFO] Reference clock 40.00 MHz
[INFO] Device name: LimeSDR-Mini
[INFO] Reference: 40 MHz
[INFO] LMS7002M calibration values caching Disable
[INFO] Selected RX path: LNAW
[INFO] Rx calibration finished
python3: src/hostapi/alsa/pa_linux_alsa.c:3641: PaAlsaStreamComponent_BeginPolling: Assertion `ret == self->nfds' failed.
[1] 12855 abort sudo python3 multi_mfm.py
[~/Desktop/PyRadio]$
So now it's an issue with Alsa?
Great news! It's working!! I trace that error up to here where they say it's an error cause by having more than one audio input.
So:
Thanks for your patience and amazing work!
Sorry last question, what do you use to play the *.if32
audio files?
You're welcome! These are interleaved Float32 files. You can use ffplay
to reproduce it:
ffplay -f f32le -ar 32000 -ac 1 *.if32
Thanks again!!
Hello thanks for sharing this project. I'm new to SDR and also to CUDA related frameworks specially for python. I'm getting the following error and I thought you can point me into the right direction: