.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/4_GPU/plot_gpu.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note You can download :ref:`below ` the full example code and run it with 🔬 `Radis-Lab `__, .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_4_GPU_plot_gpu.py: ======================= GPU Accelerated Spectra ======================= Example using GPU calculation with :py:meth:`~radis.lbl.SpectrumFactory.eq_spectrum_gpu` 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 :ref:`GPU Spectrum Calculation on RADIS ` .. note:: 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. .. GENERATED FROM PYTHON SOURCE LINES 21-60 .. image-sg:: /auto_examples/4_GPU/images/sphx_glr_plot_gpu_001.png :alt: plot gpu :srcset: /auto_examples/4_GPU/images/sphx_glr_plot_gpu_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none /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 Calculating Equilibrium Spectrum Physical Conditions ---------------------------------------- Tgas 1500.0 K Trot 1500.0 K Tvib 1500.0 K isotope 1,2,3 mole_fraction 0.8 molecule CO2 overpopulation None path_length 0.2 cm pressure 1.0 bar rot_distribution boltzmann self_absorption True state X vib_distribution boltzmann wavenum_max 2450.0000 cm-1 wavenum_min 2150.0000 cm-1 Computation Parameters ---------------------------------------- Tref 296 K add_at_used numpy broadening_method voigt cutoff 0 cm-1/(#.cm-2) dbformat hitemp-radisdb dbpath /home/docs/.radisdb/hitemp/CO2-02_02125-02250_HITEMP2010.hdf5,/home/docs/.radisdb/hitemp/CO2-02_0225... diluent air folding_thresh 1e-06 include_neighbouring_lines True memory_mapping_engine auto neighbour_lines 0 cm-1 optimization simple parfuncfmt hapi parsum_mode full summation pseudo_continuum_threshold 0 sparse_ldm False truncation 50 cm-1 waveunit cm-1 wstep 0.002 cm-1 zero_padding 150001 ---------------------------------------- 0.91s - Spectrum calculated /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.55s - Spectrum calculated (
, [, ]) | .. code-block:: Python from radis import SpectrumFactory, plot_diff sf = SpectrumFactory( 2150, 2450, # cm-1 molecule="CO2", isotope="1,2,3", wstep=0.002, ) sf.fetch_databank("hitemp") 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, backend="gpu-cuda", ) s_gpu.apply_slit(w_slit, unit="cm-1") plot_diff(s_cpu, s_gpu, var="radiance", wunit="nm", method="diff") .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 3.800 seconds) .. _sphx_glr_download_auto_examples_4_GPU_plot_gpu.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_gpu.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_gpu.py `