diegoroyo / tal

(Your)-Transient Auxiliary Library - Toolkit for simulation and analysis of time-resolved light transport captures - pip install y-tal
https://pypi.org/project/y-tal/
GNU General Public License v3.0
19 stars 4 forks source link

Hello, I have a new question #8

Closed 1languan closed 2 months ago

1languan commented 2 months ago
          Hello, I have a question. After installing the new version, when I give the command 'tal render nlos-z.yaml' , an error occurs in the program.Can you help me solve this problem?

tal render confocal-scene.yaml Traceback (most recent call last): File "/home/cx/.local/bin/tal", line 8, in sys.exit(main()) File "/home/cx/.local/lib/python3.8/site-packages/tal/main.py", line 171, in main render_nlos_scene(config_file, args) File "/home/cx/.local/lib/python3.8/site-packages/tal/render/init.py", line 30, in render_nlos_scene return render.render_nlos_scene(config_path, args) File "/home/cx/.local/lib/python3.8/site-packages/tal/render/render.py", line 509, in render_nlos_scene return _main_render(config_path, args, File "/home/cx/.local/lib/python3.8/site-packages/tal/render/render.py", line 390, in _main_render write_scene_xmls(args, mitsuba_backend, scene_config, root_dir) File "/home/cx/.local/lib/python3.8/site-packages/tal/render/render.py", line 112, in write_scene_xmls steady_xml, ground_truth_xml, nlos_xml = mitsuba_backend.get_scene_xml( File "/home/cx/.local/lib/python3.8/site-packages/tal/render/mitsuba3_transient_nlos.py", line 498, in get_scene_xml mitsuba_version=get_scene_version(), File "/home/cx/.local/lib/python3.8/site-packages/tal/render/mitsuba3_transient_nlos.py", line 48, in get_scene_version return mi.version__ AttributeError: module 'mitsuba_alias' has no attribute 'version__'

Originally posted by @1languan in https://github.com/diegoroyo/tal/issues/7#issuecomment-2257906278

diegoroyo commented 2 months ago

I'm not able to reproduce your problem. I have compiled mitsuba myself and it works on my end. Can you try these steps?

1) Does this Python snippet work for you? If yes, can you share its output?

import mitsuba as mi
mi.set_variant('scalar_rgb')
print(mi.__version__)
print(mi.variants())

2) How did you install mitsuba? What version of mitsuba are you using?

This commit https://github.com/diegoroyo/tal/commit/8a04f85bf525af907102201559763dfa7b0f19da#diff-b17c6fe69999829775eab74e71caf0ad32be9394594b5f54f5cb077d67081b48R46-R49 might help you with your problem but I am not sure as I cannot reproduce it.

1languan commented 2 months ago

Does this mean that when compiling mitsuba3, I encountered an error that prevented the mi.version function from being called? In fact, if I replace the last variant with llvm_spectral, mitsuba3 fails to compile,I have raised this question in the Project Mitsuba3 , and I would kindly request your assistance in answering this question. The link to the question is as follows:https://github.com/mitsuba-renderer/mitsuba3/issues/1240#issue-2437814895. Additionally, I have tried using pip to install mitsuba3, and in that case,this program works fine.

diegoroyo commented 2 months ago

It seems like your system is not detecting your compiled mitsuba3. Here is how I compiled mitsuba3:

cmake -GNinja -DCMAKE_CXX_COMPILER=/usr/bin/g++-11 -DCMAKE_C_COMPILER=/usr/bin/gcc-11 -DCMAKE_BUILD_TYPE=Release -DPython_EXECUTABLE=/home/droyo/.pyenv/versions/3.11.3/bin/python ..

Importantly, setting the Python_EXECUTABLE variable (you can find it using the command which python). Then, after compilation with ninja, you need to run the setpath.sh script (see https://mitsuba.readthedocs.io/en/latest/src/developer_guide/compiling.html#running-mitsuba)

It should be something like this:

source /path/to/mitsuba3/build/setpath.sh
python
>>> import mitsuba as mi
>>> mi.set_variant('scalar_rgb')
>>> print(mi.__version__)
>>> print(mi.variants())

With that you should get llvm_spectral, cuda_spectral, etc as available variants

1languan commented 2 months ago

Thank you very much. I followed your method to recompile the 3.5.2 version of Mitsuba, and it fixed the issue. />>> import mitsuba as mi

mi.set_variant('scalar_rgb') print(mi.version) 3.5.2 print(mi.variants()) ['scalar_rgb', 'scalar_spectral', 'cuda_spectral', 'llvm_spectral']

1languan commented 2 months ago

Hello, when I changed the variant in the nlos-z.yaml to llvm_spectral or cuda_spectral, I encountered the following errors. I would greatly appreciate it if you could offer some advice.

llvm_spectral

laser_emission_mode: spectrum

laser_emission: 400:1, 700:1

back_view` for nlos-z steady render...
side_view for nlos-z steady render...
ground_truth for nlos-z...
Rendering nlos-z (single)...:   0%|                       | 0/1 [00:00<?, ?it/s]/!\ Mitsuba process threw an exception:
__init__(): incompatible constructor arguments. The following argument types are supported:
    1. mitsuba.llvm_spectral.Ray3f()
    2. mitsuba.llvm_spectral.Ray3f(other: mitsuba.llvm_spectral.Ray3f)
    3. mitsuba.llvm_spectral.Ray3f(o: mitsuba.llvm_spectral.Point3f, d: mitsuba.llvm_spectral.Vector3f, time: drjit.llvm.Float = 0.0, wavelengths: mitsuba.llvm_spectral.Spectrum = [])
    4. mitsuba.llvm_spectral.Ray3f(o: mitsuba.llvm_spectral.Point3f, d: mitsuba.llvm_spectral.Vector3f, maxt: drjit.llvm.Float, time: drjit.llvm.Float, wavelengths: mitsuba.llvm_spectral.Spectrum)
    5. mitsuba.llvm_spectral.Ray3f(other: mitsuba.llvm_spectral.Ray3f, maxt: drjit.llvm.Float)
Invoked with: [[-0.5, 0.0, 0.25]], [[0.8944271802902222, 0.0, -0.4472135901451111]], 3.4028234663852886e+38, 0.0, []
Rendering nlos-z (single)...: 100%|###############| 1/1 [00:00<00:00, 36.38it/s]
Reading partial results and generating HDF5 file...
Traceback (most recent call last):
  File "/home/cx/.local/bin/tal", line 8, in <module>
    sys.exit(main())back_view for nlos-z steady render...
side_view for nlos-z steady render...
ground_truth for nlos-z...
Rendering nlos-z (single)...:   0%|                       | 0/1 [00:00<?, ?it/s]/!\ Mitsuba process threw an exception:
__init__(): incompatible constructor arguments. The following argument types are supported:
    1. mitsuba.llvm_spectral.Ray3f()
    2. mitsuba.llvm_spectral.Ray3f(other: mitsuba.llvm_spectral.Ray3f)
    3. mitsuba.llvm_spectral.Ray3f(o: mitsuba.llvm_spectral.Point3f, d: mitsuba.llvm_spectral.Vector3f, time: drjit.llvm.Float = 0.0, wavelengths: mitsuba.llvm_spectral.Spectrum = [])
    4. mitsuba.llvm_spectral.Ray3f(o: mitsuba.llvm_spectral.Point3f, d: mitsuba.llvm_spectral.Vector3f, maxt: drjit.llvm.Float, time: drjit.llvm.Float, wavelengths: mitsuba.llvm_spectral.Spectrum)
    5. mitsuba.llvm_spectral.Ray3f(other: mitsuba.llvm_spectral.Ray3f, maxt: drjit.llvm.Float)

Invoked with: [[-0.5, 0.0, 0.25]], [[0.8944271802902222, 0.0, -0.4472135901451111]], 3.4028234663852886e+38, 0.0, []
Rendering nlos-z (single)...: 100%|###############| 1/1 [00:00<00:00, 36.38it/s]
Reading partial results and generating HDF5 file...
Traceback (most recent call last):
  File "/home/cx/.local/bin/tal", line 8, in <module>
    sys.exit(main())
  File "/home/cx/.local/lib/python3.8/site-packages/tal/__main__.py", line 171, in main
    render_nlos_scene(config_file, args)
  File "/home/cx/.local/lib/python3.8/site-packages/tal/render/__init__.py", line 30, in render_nlos_scene
    return render.render_nlos_scene(config_path, args)
  File "/home/cx/.local/lib/python3.8/site-packages/tal/render/render.py", line 526, in render_nlos_scene
    return _main_render(config_path, args,
  File "/home/cx/.local/lib/python3.8/site-packages/tal/render/render.py", line 488, in _main_render
    capture_data = __merge_nlos_results(
  File "/home/cx/.local/lib/python3.8/site-packages/tal/render/render.py", line 365, in __merge_nlos_results
    capture_data.H = mitsuba_backend.read_transient_image(hdr_path)
  File "/home/cx/.local/lib/python3.8/site-packages/tal/render/mitsuba3_transient_nlos.py", line 96, in read_transient_image
    return _read_mitsuba_streakbitmap(path)
  File "/home/cx/.local/lib/python3.8/site-packages/tal/render/mitsuba3_transient_nlos.py", line 635, in _read_mitsuba_streakbitmap
    return np.load(path)
  File "/home/cx/.local/lib/python3.8/site-packages/numpy/lib/npyio.py", line 405, in load
    fid = stack.enter_context(open(os_fspath(file), "rb"))
FileNotFoundError: [Errno 2] No such file or directory: '/home/cx/tal/examples/render-reconstruct/nlos-z/20240731-155454/partial/nlos-z_L[32_0][32_0].npy'
(hdr_path)
  File "/home/cx/.local/lib/python3.8/site-packages/tal/render/mitsuba3_transient_nlos.py", line 96, in read_transient_image
    return _read_mitsuba_streakbitmap(path)
  File "/home/cx/.local/lib/python3.8/site-packages/tal/render/mitsuba3_transient_nlos.py", line 635, in _read_mitsuba_streakbitmap
    return np.load(path)
  File "/home/cx/.local/lib/python3.8/site-packages/numpy/lib/npyio.py", line 405, in load
    fid = stack.enter_context(open(os_fspath(file), "rb"))
FileNotFoundError: [Errno 2] No such file or directory: '/home/cx/tal/examples/render-reconstruct/nlos-z/20240731-155454/partial/nlos-z_L[32_0][32_0].npy'

cuda_spectral

laser_emission_mode: spectrum

laser_emission: 400:1, 700:1

Traceback (most recent call last):
File "/home/cx/.local/bin/tal", line 8, in <module>
sys.exit(main())
File "/home/cx/.local/lib/python3.8/site-packages/tal/__main__.py", line 171, in main
render_nlos_scene(config_file, args)
File "/home/cx/.local/lib/python3.8/site-packages/tal/render/__init__.py", line 30, in render_nlos_scene
return render.render_nlos_scene(config_path, args)
File "/home/cx/.local/lib/python3.8/site-packages/tal/render/render.py", line 520, in render_nlos_scene
_read_config_and_init_mitsuba_variant(config_path, args)
File "/home/cx/.local/lib/python3.8/site-packages/tal/render/render.py", line 48, in _read_config_and_init_mitsuba_variant
assert len(args.gpus) > 0, \
AssertionError: You must specify at least one GPU to use CUDA. Use tal --gpu <id1> <id2> ...
diegoroyo commented 2 months ago

Hi

For the llvm_spectral version: did you install mitransient directly from GitHub? you need this commit https://github.com/diegoroyo/mitransient/commit/6e96de24f3cc5cc3f34bef991f7e73bb2a6695ce . These changes are for your previous issue #7, and they are not uploaded to pip yet. You can clone the mitransient repo and use the provided script to install it:

$ git clone git@github.com:diegoroyo/mitransient.git
$ cd /path/to/mitransient/
$ scripts/local_install.sh

For the cuda_spectral version, you need to choose a GPU in the command line. If you only have one GPU in your system you can do

$ tal render nlos-z --gpu 0

Note that --gpu is not required when using llvm mode

With this you should be able to run the nlos-z example and get a HDF5 file as a result. However you might need to change more stuff depending on what you want to do with the spectral data (see my comment on issue #7):

At the end of the process, tal converts everything to single-wavelength. If you want to extract each spectral channel separately you would need to modify tal or access mitransient/mitsuba's data directly. This change should be relatively easy. If you want help with this please tell me how you want to store your results so I know how to help you.

1languan commented 2 months ago

Hello, with your guidance, I have recompiled mitransient, but I still have a few errors listed below. I sincerely hope you can assist me in resolving them. For the llvm_spectral version:

tal render nlos-z.yaml
back_view for nlos-z steady render...
side_view for nlos-z steady render...
ground_truth for nlos-z...
Rendering nlos-z (single)...:   0%|                  /!\ Mitsuba process threw an exception:                                         
module 'drjit' has no attribute 'ADMode'
Rendering nlos-z (single)...: 100%|###############| 1/1 [00:00<00:00,  9.57it/s]
Reading partial results and generating HDF5 file...
Traceback (most recent call last):
  File "/home/cx/.local/bin/tal", line 8, in <module>
    sys.exit(main())
  File "/home/cx/.local/lib/python3.8/site-packages/tal/__main__.py", line 171, in main
    render_nlos_scene(config_file, args)
  File "/home/cx/.local/lib/python3.8/site-packages/tal/render/__init__.py", line 30, in render_nlos_scene
    return render.render_nlos_scene(config_path, args)
  File "/home/cx/.local/lib/python3.8/site-packages/tal/render/render.py", line 526, in render_nlos_scene
    return _main_render(config_path, args,
  File "/home/cx/.local/lib/python3.8/site-packages/tal/render/render.py", line 488, in _main_render
    capture_data = __merge_nlos_results(
  File "/home/cx/.local/lib/python3.8/site-packages/tal/render/render.py", line 365, in __merge_nlos_results
    capture_data.H = mitsuba_backend.read_transient_image(hdr_path)
  File "/home/cx/.local/lib/python3.8/site-packages/tal/render/mitsuba3_transient_nlos.py", line 96, in read_transient_image
    return _read_mitsuba_streakbitmap(path)
  File "/home/cx/.local/lib/python3.8/site-packages/tal/render/mitsuba3_transient_nlos.py", line 635, in _read_mitsuba_streakbitmap
    return np.load(path)
  File "/home/cx/.local/lib/python3.8/site-packages/numpy/lib/npyio.py", line 405, in load
    fid = stack.enter_context(open(os_fspath(file), "rb"))
FileNotFoundError: [Errno 2] No such file or directory: '/home/cx/tal/examples/render-reconstruct/nlos-z/20240731-204412/partial/nlos-z_L[32_0][32_0].npy'

For the cuda_spectral version:

tal render nlos-z.yaml --gpu 0
back_view for nlos-z steady render...
side_view for nlos-z steady render...
ground_truth for nlos-z...
Rendering nlos-z (single)...:   0%|          | 0/1 [0/!\ Mitsuba process threw an exception::   0%|          | 0/100 [00:00<?, ?it/s]

module 'drjit' has no attribute 'ADMode'

Rendering nlos-z (single)...: 100%|##########| 1/1 [00:00<00:00,  4.25it/s]
Reading partial results and generating HDF5 file...  
Traceback (most recent call last):
diegoroyo commented 2 months ago

module 'drjit' has no attribute 'ADMode'

It has to do with the compilation of Mitsuba 3, in the build/mitsuba.conf file you need to add at least one _ad_ variant. Otherwise the drjit module (which tal/mitransient depend on) will be missing some features.

"enabled": [
    "scalar_rgb", "scalar_spectral", "cuda_spectral", "llvm_spectral"
],

I would change this to

"enabled": [
    "scalar_rgb", "scalar_spectral", "cuda_spectral", "cuda_ad_spectral", "llvm_spectral", "llvm_ad_spectral"
],

and recompile Mitsuba 3 (run both cmake and ninja again). I will clarify this in the documentation as it can be a bit counterintuitive, thanks.

1languan commented 2 months ago

Thank you very much. I recompiled Mitsuba 3 and it works now.

Panjaksli commented 1 month ago

module 'drjit' has no attribute 'ADMode'

It has to do with the compilation of Mitsuba 3, in the build/mitsuba.conf file you need to add at least one _ad_ variant. Otherwise the drjit module (which tal/mitransient depend on) will be missing some features.

"enabled": [
    "scalar_rgb", "scalar_spectral", "cuda_spectral", "llvm_spectral"
],

I would change this to

"enabled": [
    "scalar_rgb", "scalar_spectral", "cuda_spectral", "cuda_ad_spectral", "llvm_spectral", "llvm_ad_spectral"
],

and recompile Mitsuba 3 (run both cmake and ninja again). I will clarify this in the documentation as it can be a bit counterintuitive, thanks.

So why not mention that you need at least one ad variant in order to even compile in the only available build instructions ? You only mention scalar_rgb is mandatory, and one of ad variants only recommended: https://mitsuba.readthedocs.io/en/stable/src/developer_guide/compiling.html

I've pointlessly wasted 16 hours trying to decipher cryptic linking errors, reconfigure compilers on Windows, giving up and installing Linux and again re-configuring compilers and build systems there, just because I didn't need any differentiation.

diegoroyo commented 1 month ago

@Panjaksli Sorry to hear that. If you are referring to this link: https://mitsuba.readthedocs.io/en/stable/src/developer_guide/compiling.html, keep in mind that Mitsuba 3 is different from mitransient and tal. I am not an author of the original Mitsuba 3 repo so that link is not maintained by me. You will need to follow the instructions for mitransient, which is our extension to Mitsuba 3. In the repo for mitransient we state that:

If you have installed Mitsuba 3 via pip you will only have access to the llvm_ad_rgb and cuda_ad_rgb variants. If you want to use other variants (e.g. NLOS simulations can greatly benefit from the llvm_mono variant which only propagates one wavelength), then we recommend that you compile Mitsuba 3 yourself following this tutorial and enable the following variants: ["scalar_mono", "llvm_mono", "llvm_ad_mono", "cuda_mono", "cuda_ad_mono", "scalar_rgb", "llvm_rgb", "llvm_ad_rgb", "cuda_rgb", "cuda_ad_rgb"].

So we are not in control of the documentation of Mitsuba 3. If you feel that we can improve mitransient or tal's documentation in any way, suggestions are welcome (of course).

If you need further assistance let me know, will be happy to help

Panjaksli commented 1 month ago

@Panjaksli Sorry to hear that. If you are referring to this link: https://mitsuba.readthedocs.io/en/stable/src/developer_guide/compiling.html, keep in mind that Mitsuba 3 is different from mitransient and tal. I am not an author of the original Mitsuba 3 repo so that link is not maintained by me. You will need to follow the instructions for mitransient, which is our extension to Mitsuba 3. In the repo for mitransient we state that:

If you have installed Mitsuba 3 via pip you will only have access to the llvm_ad_rgb and cuda_ad_rgb variants. If you want to use other variants (e.g. NLOS simulations can greatly benefit from the llvm_mono variant which only propagates one wavelength), then we recommend that you compile Mitsuba 3 yourself following this tutorial and enable the following variants: ["scalar_mono", "llvm_mono", "llvm_ad_mono", "cuda_mono", "cuda_ad_mono", "scalar_rgb", "llvm_rgb", "llvm_ad_rgb", "cuda_rgb", "cuda_ad_rgb"].

So we are not in control of the documentation of Mitsuba 3. If you feel that we can improve mitransient or tal's documentation in any way, suggestions are welcome (of course).

If you need further assistance let me know, will be happy to help

Actually my bad...

I've searched through the original Mitsuba repo issues through the searchbar, because I was tearing my hair out, and found this. I haven't noticed (nor did I think it was possible), that the issue I found was under completely different repository.

Sorry for any inconvenience, I'm gonna contact the original author.

diegoroyo commented 1 month ago

No worries. As I said if you need further assistance feel free to let me know