Real-time GPU Accelerated Spectra (Interactive)

Example using GPU sliders and GPU calculation with eq_spectrum_gpu_intereactive()

This method requires a GPU - Currently, only Nvidia GPU’s are supported. For more information on how to setup your system to run GPU-accelerated methods using CUDA, check GPU Spectrum Calculation on RADIS

Note

In some cases matplotlib immediately closes the window and returns; this is solved by running python in interactive mode as follows: python -i plot_gpu_widgets.py.

in the example below, the code runs on the GPU by default. In case no Nvidia GPU is detected, the code will instead be ran on CPU. This can be toggled manually by setting the backend keyword either to 'gpu-cuda' or 'cpu-cuda'. The run time reported below is for CPU.

plot gpu widgets
In ``/home/docs/.radisdb/hitemp`` keep only relevant input files:
/home/docs/.radisdb/hitemp/CO2-02_02125-02250_HITEMP2010.hdf5
/home/docs/.radisdb/hitemp/CO2-02_02250-02500_HITEMP2010.hdf5
Can't find libcuda.so.1...
/home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/radis/gpu/gpu.py:112: NoGPUWarning:

Failed to load CUDA context, this happened either becauseCUDA is not installed properly, or you have no NVIDIA GPU. Continuing with emulated GPU on CPU...This means *NO* GPU acceleration!

Number of lines loaded: 1128265

mode: CPU
Finished calculating spectrum!
0.59s - Spectrum calculated

from radis import SpectrumFactory
from radis.tools.plot_tools import ParamRange

sf = SpectrumFactory(
    2150,
    2450,  # cm-1
    molecule="CO2",
    isotope="1,2,3",
    wstep=0.002,
)

sf.fetch_databank("hitemp")

s = sf.eq_spectrum_gpu_interactive(
    var="radiance",
    Tgas=ParamRange(300.0, 2500.0, 1500.0),  # K
    pressure=ParamRange(0.1, 2, 1),  # bar
    mole_fraction=ParamRange(0, 1, 0.8),
    path_length=ParamRange(0, 1, 0.2),  # cm
    slit_function=ParamRange(0, 1.5, 0.5),  # cm-1
    plotkwargs={"wunit": "nm"},  # "nfig": "same",
)

Total running time of the script: (0 minutes 3.126 seconds)