GPU Accelerated Spectra (recalc_gpu() demo)ΒΆ

Example using GPU calculation with recalc_gpu()

After producing a spectrum object with sf.eq_spectrum_gpu(), new spectra can be produced quickly with spectrum.recalc_gpu().

Note

make sure you pass exit_gpu=False when producing the spectrum object, otherwise it will destroy the GPU context which is needed for spectrum.recalc_gpu(). Also be sure to call gpu_exit() at the end.

plot gpu recalc
/home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/radis/db/molparam.py:252: FutureWarning:

The 'delim_whitespace' keyword in pd.read_csv is deprecated and will be removed in a future version. Use ``sep='\s+'`` instead

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
/home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/radis/lbl/factory.py:1107: FutureWarning:

Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead

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.52s - Spectrum calculated
Plot1 finished in  521.5 ms
Plot2 finished in  378.7 ms
Plot3 finished in  432.5 ms

from radis import SpectrumFactory
from radis.gpu.gpu import gpu_exit

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

sf.fetch_databank("hitemp")

T_list = [1000.0, 1500.0, 2000.0]

s = sf.eq_spectrum_gpu(
    Tgas=T_list[0],  # K
    pressure=1,  # bar
    mole_fraction=0.8,
    path_length=0.2,  # cm
    exit_gpu=False,
)
s.apply_slit(0.5, unit="cm-1")  # cm-1
print("Plot1 finished in {:6.1f} ms".format(s.conditions["calculation_time"] * 1e3))
s.plot("radiance", wunit="nm", show=False)

s.recalc_gpu(Tgas=T_list[1])
print("Plot2 finished in {:6.1f} ms".format(s.conditions["calculation_time"] * 1e3))
s.plot("radiance", wunit="nm", show=False, nfig="same")

s.recalc_gpu(Tgas=T_list[2])
print("Plot3 finished in {:6.1f} ms".format(s.conditions["calculation_time"] * 1e3))
s.plot("radiance", wunit="nm", show=True, nfig="same")

gpu_exit()

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