Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot import XML file into Sionna #608

Closed
pablocanosanroman opened this issue Oct 4, 2024 · 14 comments
Closed

Cannot import XML file into Sionna #608

pablocanosanroman opened this issue Oct 4, 2024 · 14 comments

Comments

@pablocanosanroman
Copy link

Hello,
I am trying create my own scene with Blender using OpenStreetMaps. I have followed this tutorial: Sionna RT: Scene Creation with Blender using OpenStreetMap and when it is time to load the scene in sionna I get this error:

RuntimeError                              Traceback (most recent call last)
Cell In[6], line 1
----> 1 scene = load_scene(sionna.rt.scene.londonWhitehall)

File ~/sionna/sionna/rt/scene.py:1942, in load_scene(filename, dtype)
   1940 if filename is None:
   1941     filename = "__empty__"
-> 1942 return Scene(filename, dtype=dtype)

File ~/sionna/sionna/rt/scene.py:144, in Scene.__init__(self, env_filename, dtype)
    139     self._scene = mi.load_dict({"type": "scene",
    140                                 "integrator": {
    141                                     "type": "path",
    142                                 }})
    143 else:
--> 144     self._scene = mi.load_file(env_filename)
    145 self._scene_params = mi.traverse(self._scene)
    147 # Instantiate the solver

RuntimeError: ​[xml.cpp:1079] Error while loading "/home/pablo/sionna/sionna/rt/scenes/london_whitehall/LondonWhitehall.xml" (near line 17748, col 3): could not instantiate shape plugin of type "ply": 
[xml.cpp:1079]   [PLYMesh] Error while loading PLY file "Be_at_One-itu_marble.ply": file not found!

I am using this code to load the scene:

scene = load_scene(sionna.rt.scene.londonWhitehall)

I have added londonWhitehall in the scene.py file, so I can access it easily, so added this line in that file:

londonWhitehall = str(files(scenes).joinpath("london_whitehall/LondonWhitehall.xml"))

I have followed the discussion #357 to try fix it but nothing I have tried has worked. Do you know any way to fix this?

@faycalaa
Copy link
Collaborator

faycalaa commented Oct 7, 2024

Hi @pablocanosanroman,

It seems that Mitsuba is unable to locate the mesh files. Could they be in a sub-folder of london_whitehall, such as london_whitehall/meshes? If so, the path to the mesh files in the XML file should reflect this (e.g., meshes/Be_at_One-itu_marble.ply).

@pablocanosanroman
Copy link
Author

Yes, the meshes are in a subfolder of london_whitehall. Inside the folder I have the XML file and the meshes folder.

image

I checked inside the XML file, and this is the example of that specific building.

<shape type="ply" id="mesh-Be_At_One-itu_marble" name="mesh-Be_At_One-itu_marble"> <string name="filename" value="meshes/Be_At_One-itu_marble.ply"/> <boolean name="face_normals" value="true"/> <ref id="mat-itu_marble" name="bsdf"/>

Also, I am using Ubuntu and WSL for Sionna. When I try to export the xml file directly to the folder in WSL, I get some errors in Blender and the xml file does not export correctly. So I am exporting it in a folder on my local disk and then copying and pasting the xml file and meshes folder into the sionna scenes folder inside Ubuntu WSL.

image

Could this be a reason for this not working?

@merlinND
Copy link
Collaborator

merlinND commented Oct 7, 2024

Hello @pablocanosanroman,

A few people have reported similar issues in the past, but so far it was always due to actual problems with the files not being there.
Are you certain that all the mesh files are present in the meshes/ directory, that they have the correct names, that the permissions are correct, that you are loading the right XML file, etc?

@pablocanosanroman
Copy link
Author

This is the file being loaded when using load_scene(sionna.rt.scene.londonWhitehall) :

londonWhitehall = str(files(scenes).joinpath("london_whitehall/LondonWhitehall.xml"))

image

image

It is the correct path to the XML file I want to load.

At least the ply file that is giving me the error is in the meshes folder and has the right name. There are so many files, so checking it one by one would take me forever.

image

And about permissions, how do I check if I have permissions to access the ply file?

Also, I found out that if I try to open the ply file in the jupyter notebook I get this message.

image

And this is the message I get in VS code if I try opening it through the file explorer.

image

@merlinND
Copy link
Collaborator

merlinND commented Oct 8, 2024

The last two messages ("not UTF-8 encoded", "unsupported text encoding") should be fine because the .ply files are typically stored in binary format for efficiency.

To check permissions, you can use e.g. ls -la meshes/* in your scene's directory.

You mentioned that you added your scene as sionna.rt.scene.londonWhitehall. Did you try passing the path to the scene file directly to load_scene(), instead of going through the sionna.rt.scene.londonWhitehall variable?

Another thing to check is that the scene loads correctly when only using Mitsuba. For example:

import mitsuba as mi

mi.set_variant("cuda_ad_rgb")  # Or "llvm_ad_rgb" if that's what you plan to use

scene = mi.load_xml("/full/path/to/london_whitehall/LondonWhitehall.xml")
print(scene)

@pablocanosanroman
Copy link
Author

It seems that the permissions are fine. When I write the command in ubuntu, I get this output.

image

I did try using just the path, and the same error appears.

image

When I try loading the XML with mitsuba I get this error. Which I do not understand because I am using CUDA at the moment.

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
File ~/.local/lib/python3.11/site-packages/mitsuba/__init__.py:107, in MitsubaVariantModule.__getattribute__(self, key)
    104 with _dr.scoped_rtld_deepbind():
    105     modules = (
    106         _import('mitsuba.mitsuba_ext'),
--> 107         _import('mitsuba.mitsuba_' + variant + '_ext'),
    108     )
    110 super().__setattr__('_modules', modules)

File /usr/local/lib/python3.11/importlib/__init__.py:126, in import_module(name, package)
    125         level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)

File <frozen importlib._bootstrap>:1206, in _gcd_import(name, package, level)

File <frozen importlib._bootstrap>:1178, in _find_and_load(name, import_)

File <frozen importlib._bootstrap>:1149, in _find_and_load_unlocked(name, import_)

File <frozen importlib._bootstrap>:676, in _load_unlocked(spec)

File <frozen importlib._bootstrap>:573, in module_from_spec(spec)

File <frozen importlib._bootstrap_external>:1233, in create_module(self, spec)

File <frozen importlib._bootstrap>:241, in _call_with_frames_removed(f, *args, **kwds)

ImportError: jit_cuda_init(): the CUDA backend is not available because cuInit() failed.
There are two common explanations for this type of failure:

 1. your computer simply does not contain a graphics card that supports CUDA.

 2. your CUDA kernel module and CUDA library are out of sync. Try to see if you
    can run a utility like 'nvidia-smi'. If not, a reboot will likely fix this
    issue. Otherwise reinstall your graphics driver. 

 The specific error message produced by cuInit was
   "no CUDA-capable device is detected"

During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)
Cell In[3], line 2
      1 import mitsuba as mi
----> 2 mi.set_variant("cuda_ad_rgb")
      4 scene = mi.load_xml("sionna/rt/scenes/london_whitehall/LondonWhitehall.xml")
      5 #scene = load_scene("sionna/rt/scenes/london_whitehall/LondonWhitehall.xml")

File ~/.local/lib/python3.11/site-packages/mitsuba/__init__.py:315, in MitsubaModule.set_variant(self, *args)
    313 import sys
    314 if 'mitsuba.ad.integrators' in _sys.modules:
--> 315     _reload(_sys.modules['mitsuba.ad.integrators'])
    316 else:
    317     _import('mitsuba.ad.integrators')

File /usr/local/lib/python3.11/importlib/__init__.py:169, in reload(module)
    167 if spec is None:
    168     raise ModuleNotFoundError(f"spec not found for the module {name!r}", name=name)
--> 169 _bootstrap._exec(spec, module)
    170 # The module may have replaced itself in sys.modules!
    171 return sys.modules[name]

File <frozen importlib._bootstrap>:621, in _exec(spec, module)

File <frozen importlib._bootstrap_external>:940, in exec_module(self, module)

File <frozen importlib._bootstrap>:241, in _call_with_frames_removed(f, *args, **kwds)

File ~/.local/lib/python3.11/site-packages/mitsuba/python/ad/integrators/__init__.py:15
     12 if mitsuba.variant() is not None and not mitsuba.variant().startswith('scalar'):
     13     # Make sure `common.py` is reloaded before the integrators
     14     if do_reload:
---> 15         importlib.reload(globals()['common'])
     17     for f in glob.glob(os.path.join(os.path.dirname(__file__), "*.py")):
     18         if not os.path.isfile(f) or f.endswith('__init__.py'):

File /usr/local/lib/python3.11/importlib/__init__.py:169, in reload(module)
    167 if spec is None:
    168     raise ModuleNotFoundError(f"spec not found for the module {name!r}", name=name)
--> 169 _bootstrap._exec(spec, module)
    170 # The module may have replaced itself in sys.modules!
    171 return sys.modules[name]

File <frozen importlib._bootstrap>:621, in _exec(spec, module)

File <frozen importlib._bootstrap_external>:940, in exec_module(self, module)

File <frozen importlib._bootstrap>:241, in _call_with_frames_removed(f, *args, **kwds)

File ~/.local/lib/python3.11/site-packages/mitsuba/python/ad/integrators/common.py:8
      4 import drjit as dr
      5 import gc
----> 8 class ADIntegrator(mi.CppADIntegrator):
      9     """
     10     Abstract base class of numerous differentiable integrators in Mitsuba
     11 
   (...)
     25          visible surfaces. (Default: 5)
     26     """
     28     def __init__(self, props = mi.Properties()):

File ~/.local/lib/python3.11/site-packages/mitsuba/__init__.py:253, in MitsubaModule.__getattribute__(self, key)
    251     sub_suffix = '' if submodule is None else f'.{submodule}'
    252     module = _sys.modules[f'mitsuba.{variant}{sub_suffix}']
--> 253     result = module.__getattribute__(key)
    255 # Add set_variant(), variant() and variant modules to the __dict__
    256 if submodule is None and key == '__dict__':

File ~/.local/lib/python3.11/site-packages/mitsuba/__init__.py:115, in MitsubaVariantModule.__getattribute__(self, key)
    113         raise AttributeError('Mitsuba variant "%s" not found.' % variant)
    114     else:
--> 115         raise AttributeError(e)
    116 finally:
    117     # Remove those modules from _sys.modules as only the
    118     # MitsubaVariantModule instance should hold a reference to them.
    119     _sys.modules.pop('mitsuba.mitsuba_ext', None)

AttributeError: jit_cuda_init(): the CUDA backend is not available because cuInit() failed.
There are two common explanations for this type of failure:

 1. your computer simply does not contain a graphics card that supports CUDA.

 2. your CUDA kernel module and CUDA library are out of sync. Try to see if you
    can run a utility like 'nvidia-smi'. If not, a reboot will likely fix this
    issue. Otherwise reinstall your graphics driver. 

 The specific error message produced by cuInit was
   "no CUDA-capable device is detected"

@pablocanosanroman
Copy link
Author

When I use "nvidia-smi" this is what it shows.

image

@pablocanosanroman
Copy link
Author

Hello, I am still having this problem, does anyone know a possible solution? Thank you in advance.

@merlinND
Copy link
Collaborator

Could you please share the full scene (including mesh files), I can try locally to see if there's anything wrong with the scene itself.

@pablocanosanroman
Copy link
Author

Here I upload a zip file with the xml file and meshes.
london_whitehall.zip

Do you also need the blender file?

@pablocanosanroman
Copy link
Author

I made it work! The problem was that when I exported the xml file in Blender I was exporting it to a specific folder on my C drive and I was then moving the files into a WSL folder (Where I have Sionna installed). When I locate the xml file directly in the c drive it works.

scene = load_scene("/mnt/c/OpenStreetMapsScenes/LondonWhitehall.xml")

@merlinND
Copy link
Collaborator

I looked at the scene file that you send over and I think I figured it out.

In the XML file, there are a few shapes that are referring to the "same" building, but with names that use different capitalization. For example (Soho_Coffee_co_ vs Soho_Coffee_Co_):

	<shape type="ply" id="mesh-Soho_Coffee_co_-itu_marble" name="mesh-Soho_Coffee_co_-itu_marble">
		<string name="filename" value="meshes/Soho_Coffee_co_-itu_marble.ply"/>
		<boolean name="face_normals" value="true"/>
		<ref id="mat-itu_marble" name="bsdf"/>
	</shape>

        ...

	<shape type="ply" id="mesh-Soho_Coffee_Co_-itu_marble" name="mesh-Soho_Coffee_Co_-itu_marble">
		<string name="filename" value="meshes/Soho_Coffee_Co_-itu_marble.ply"/>
		<boolean name="face_normals" value="true"/>
		<ref id="mat-itu_marble" name="bsdf"/>
	</shape>

Because you exported the scenes on Windows, which uses a case insensitive file system, the similarly-named meshes were only being written into only 1 file.
But then, when trying to load the scene on Linux, it would look for the different mesh files in a case-sensitive way, and would fail since they aren't there.

In other words, the error message from your first post:

Error while loading PLY file "Be_at_One-itu_marble.ply": file not found!

was correct. There is really no file named meshes/Be_at_One-itu_marble.ply file, only meshes/Be_At_One-itu_marble.ply.

@merlinND
Copy link
Collaborator

In the end, only 3 shapes had this issue:

  • Be_at_One-itu_marble.ply
  • Bloobloom-itu_glass.ply
  • Soho_Coffee_co_-itu_marble.ply

You could maybe go back to Blender, search the objects list and check if those buildings were accidentally duplicated.
Otherwise, you can simply comment out or rename the extra Shape entry in your XML file directly.

@pablocanosanroman
Copy link
Author

Oh nice thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants