.. 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_recalc.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_recalc.py: ======================= GPU Accelerated Spectra (recalc_gpu() demo) ======================= Example using GPU calculation with :py:meth:`~radis.spectrum.spectrum.Spectrum.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. .. GENERATED FROM PYTHON SOURCE LINES 19-55 .. image-sg:: /auto_examples/4_GPU/images/sphx_glr_plot_gpu_recalc_001.png :alt: plot gpu recalc :srcset: /auto_examples/4_GPU/images/sphx_glr_plot_gpu_recalc_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 /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 | .. code-block:: Python 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() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.727 seconds) .. _sphx_glr_download_auto_examples_4_GPU_plot_gpu_recalc.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_recalc.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_gpu_recalc.py `