GPU Accelerated Spectra¶
Example using GPU calculation with eq_spectrum_gpu()
Note
Systems with a dedicated GPU often have multiple devices available, because they also have an integrated GPU in the main processor. This can be selected by chosing a different device_id (e.g. ânvidiaâ or âintelâ). The device id could be a string or an integer. The integer is the device number, starting from 0. Look at the device overview printed when running the GPU spectrum to see what options are available.
Make sure to call gpu_exit() at the end to release all GPU resources. This canât be done automatically because Radis doesnât know how long you want to keep using the GPU. If you want to immediately exit the GPU calculations, the keyword exit_gpu=True can be passed to sf.eq_spectrum_gpu(), but this is uncommon because it doesnât leverage the full power of GPU calculations.

--------------------------------------------------------------------------------
CO2 - HITRAN - Downloading database
--------------------------------------------------------------------------------
Download:
- All files already downloaded.
Caching to HDF5/H5 format:
- All files already cached.
0.05s - Loaded database
/home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/radis/misc/warning.py:434: HighTemperatureWarning: HITRAN is valid for low temperatures (typically < 700 K). For higher temperatures you may need HITEMP or CDSD. See the 'databank=' parameter
warnings.warn(WarningType(message))
Calculating Equilibrium Spectrum
Physical Conditions
----------------------------------------
Tgas 1500.0 K
isotope 1
medium air
mole_fraction 0.8
path_length 0.2 cm
pressure 1.0 bar
self_absorption True
species CO2
state X
wavenum_max 2450.0000 cm-1
wavenum_min 2150.0000 cm-1
Computation Parameters
----------------------------------------
Tref 296 K
add_at_used numpy
broadening_method voigt_poly
cutoff 0 cm-1/(#.cm-2)
dbformat hitran
dbpath /home/docs/.radisdb/hitran/CO2.h5
diluent air
folding_thresh 1e-06
include_neighbouring_lines True
isatom False
isneutral None
lbfunc None
memory_mapping_engine auto
neighbour_lines 0 cm-1
optimization simple
parsum_mode full summation
pfsource default
potential_lowering None
pseudo_continuum_threshold 0
sparse_ldm True
truncation 50 cm-1
waveunit cm-1
wstep 0.002 cm-1
zero_padding 150001
----------------------------------------
0.14s - Spectrum calculated
Slice 1/1
/home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/radis/misc/warning.py:434: HighTemperatureWarning: HITRAN is valid for low temperatures (typically < 700 K). For higher temperatures you may need HITEMP or CDSD. See the 'databank=' parameter
warnings.warn(WarningType(message))
Vulkan version: 1.3.275.1
Selected device (device_id = 0):
[X] 0: llvmpipe (LLVM 15.0.7, 256 bits)
Finished calculating spectrum!
6.86s - Spectrum calculated
Slice 1/1
(<Figure size 640x480 with 2 Axes>, [<Axes: >, <Axes: xlabel='Wavelength (nm)'>])
from radis import SpectrumFactory, plot_diff
sf = SpectrumFactory(
2150,
2450, # cm-1
molecule="CO2",
isotope="1",
wstep=0.002,
)
sf.fetch_databank(
source="hitran"
) # use hitemp or exomol for accuracy at high tempertatures
T = 1500.0 # K
p = 1.0 # bar
x = 0.8
l = 0.2 # cm
w_slit = 0.5 # cm-1
s_cpu = sf.eq_spectrum(
name="CPU",
Tgas=T,
pressure=p,
mole_fraction=x,
path_length=l,
)
s_cpu.apply_slit(w_slit, unit="cm-1")
s_gpu = sf.eq_spectrum_gpu(
name="GPU",
Tgas=T,
pressure=p,
mole_fraction=x,
path_length=l,
# device_id='nvidia',
exit_gpu=True,
)
s_gpu.apply_slit(w_slit, unit="cm-1")
plot_diff(s_cpu, s_gpu, var="emissivity", wunit="nm", method="diff")
# s_gpu.exit_gpu()
Total running time of the script: (0 minutes 7.682 seconds)