radis / radis-lab

Online environment for advanced spectrum processing and comparison with experimental data
https://radis.github.io/radis-lab
5 stars 7 forks source link

Radis on Colab with GPU #28

Open erwanp opened 3 years ago

erwanp commented 3 years ago

A first attempt to run RADIS on Google-colab with GPU (note that GPU must be enabled in Edit / Notebook settings)

https://colab.research.google.com/drive/1RnbAm_YIBZJW-7fEXp60oGFX8iAt_951#scrollTo=WRHD7xue_-yw

!pip install radis

Got radis 0.10.3

from radis import calc_spectrum
s = calc_spectrum(1900, 2300,         # cm-1
                  molecule='CO',
                  isotope='1,2,3',
                  pressure=1.01325,   # bar
                  Tgas=700,           # K
                  mole_fraction=0.1,
                  path_length=1,      # cm
                  databank='hitemp',  # or use 'hitemp'
                  verbose=False,
                  mode='gpu'
                  )
s.apply_slit(0.5, 'nm')       # simulate an experimental slit
s.plot('radiance')

Failed with the following :

RADIS configuration file created in /root/radis.json
Added HITEMP-CO database in /root/radis.json
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-3-428ebed103f5> in <module>()
      9                   databank='hitemp',  # or use 'hitemp'
     10                   verbose=False,
---> 11                   mode='gpu'
     12                   )
     13 s.apply_slit(0.5, 'nm')       # simulate an experimental slit

3 frames
/usr/local/lib/python3.7/dist-packages/radis/lbl/gpu.py in <module>()
     67 # TO-DO: read and compile CUDA code at install time, then pickle the cuda object
     68 cuda_fname = join(getProjectRoot(), "lbl", "gpu.cu")
---> 69 with open(cuda_fname, "rb") as f:
     70     cuda_code = f.read().decode()
     71 

FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/lib/python3.7/dist-packages/radis/lbl/gpu.cu'
erwanp commented 3 years ago

@dcmvdbekerom this will be a good test for the GPU code too !

dcmvdbekerom commented 3 years ago

At some point the file was renamed to "gpu.cpp" to allow for cpu/gpu hybrid code ('emulated GPU'). Replacing "gpu.cu" with "gpu.cpp" should do the trick, though the fact that it's not updated might be indicative that there are still some issues with merging..