metadriverse / metadrive

MetaDrive: Open-source driving simulator
https://metadriverse.github.io/metadrive/
Apache License 2.0
797 stars 112 forks source link

Cannot find "/usr/lib/dri/swrast_dri.so" #654

Closed rgu01 closed 9 months ago

rgu01 commented 9 months ago

OS: Linux Ubuntu 22.04.3 LTS Processor: Intel® Core™ i5-8250U CPU @ 1.60GHz × 4 Graphics: llvmpipe (LLVM 15.0.7, 256 bits) Virtual machine: Oracle VirtualBox Version 7.0.10 r158379 Environment: miniconda3 Issue: After strictly following the installation steps, running "python -m metadrive.examples.drive_in_single_agent_env" generates the following the errors:

[INFO] Environment: MetaDriveEnv [INFO] MetaDrive version: 0.4.2.3 [INFO] Sensors: [lidar: Lidar(), side_detector: SideDetector(), lane_line_detector: LaneLineDetector(), main_camera: MainCamera(1200, 900), dashboard: DashBoard()] [INFO] Render Mode: onscreen [INFO] Horizon (Max steps per agent): None [INFO] Assets version: 0.4.2.3 Xlib: extension "XFree86-DGA" missing on display ":0". libGL error: MESA-LOADER: failed to open swrast: /usr/lib/dri/swrast_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)

Running the following command can obtain the path of swrast_dri.so in my system: find / -name swrast_dri.so 2>/dev/null Result: /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so

"Search paths" seem include the path of swrast_dri.so in my system, but it cannot find the file?

QuanyiLi commented 9 months ago

Do you try creating a soft link for swrast_dri.so?

rgu01 commented 9 months ago

Do you try creating a soft link for swrast_dri.so?

No, I did not try any fix. I thought it was a problem with the tool as I just followed the instructions in a new Ubuntu VM and did nothing complex. Do you mean add "/usr/lib/x86_64-linux-gnu/dri/swrast_dri.so" in the PATH variable?

QuanyiLi commented 9 months ago

No, I mean you can do ln -s /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so /usr/lib/dri/swrast_dri.so, which will create a soft copy for the missing .so

QuanyiLi commented 9 months ago

We didn't run MetaDrive in a Virtual machine before... I think the virtual machine has poor support for GPU, so the rendering could be slow. If you are playing Ubuntu on windows platform, maybe you can try WSL2, which provides native support for linux on windows.

rgu01 commented 9 months ago

Switched to my M2 chip MacBook Pro. Created a new conda environment. Installed MetaDrive from zero in the new environment. Run "python -m metadrive.examples.verify_headless_installation" and get the following issues:

[INFO] Environment: MetaDriveEnv [INFO] MetaDrive version: 0.4.2.3 [INFO] Sensors: [lidar: Lidar(), side_detector: SideDetector(), lane_line_detector: LaneLineDetector()] [INFO] Render Mode: none [INFO] Horizon (Max steps per agent): None [INFO] Assets version: 0.4.2.3 [INFO] Known Pipes: CocoaGraphicsPipe [INFO] Start Scenario Index: 0, Num Scenarios : 1 [INFO] Episode ended! Scenario Index: 0 Reason: out_of_road. Bullet physics world is launched successfully! [INFO] Environment: MetaDriveEnv [INFO] MetaDrive version: 0.4.2.3 [INFO] Sensors: [lidar: Lidar(), side_detector: SideDetector(), lane_line_detector: LaneLineDetector(), rgb_camera: RGBCamera(256, 256), depth_camera: DepthCamera(256, 256)] [INFO] Render Mode: offscreen [INFO] Horizon (Max steps per agent): None Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "/Users/rgu01/Library/CloudStorage/OneDrive-Mälardalensuniversitet/Documents/Programs/scenarionet/metadrive/metadrive/examples/verify_headless_installation.py", line 11, in verify_installation(args.cuda, args.camera) File "/Users/rgu01/Library/CloudStorage/OneDrive-Mälardalensuniversitet/Documents/Programs/scenarionet/metadrive/metadrive/tests/test_installation.py", line 84, in verify_installation capture_headless_image(cuda) File "/Users/rgu01/Library/CloudStorage/OneDrive-Mälardalensuniversitet/Documents/Programs/scenarionet/metadrive/metadrive/tests/test_installation.py", line 14, in capture_headless_image env = MetaDriveEnv( ^^^^^^^^^^^^^ File "/Users/rgu01/Library/CloudStorage/OneDrive-Mälardalensuniversitet/Documents/Programs/scenarionet/metadrive/metadrive/envs/metadrive_env.py", line 103, in init super(MetaDriveEnv, self).init(config) File "/Users/rgu01/Library/CloudStorage/OneDrive-Mälardalensuniversitet/Documents/Programs/scenarionet/metadrive/metadrive/envs/base_env.py", line 302, in init self.agent_manager = self._get_agent_manager() ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/rgu01/Library/CloudStorage/OneDrive-Mälardalensuniversitet/Documents/Programs/scenarionet/metadrive/metadrive/envs/base_env.py", line 399, in _get_agent_manager return VehicleAgentManager(init_observations=self._get_observations()) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/rgu01/Library/CloudStorage/OneDrive-Mälardalensuniversitet/Documents/Programs/scenarionet/metadrive/metadrive/envs/base_env.py", line 396, in _get_observations return {DEFAULT_AGENT: self.get_single_observation()} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/rgu01/Library/CloudStorage/OneDrive-Mälardalensuniversitet/Documents/Programs/scenarionet/metadrive/metadrive/envs/base_env.py", line 670, in get_single_observation o = ImageStateObservation(self.config) if img_obs else LidarStateObservation(self.config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/rgu01/Library/CloudStorage/OneDrive-Mälardalensuniversitet/Documents/Programs/scenarionet/metadrive/metadrive/obs/image_obs.py", line 26, in init self.img_obs = ImageObservation(config, config["vehicle_config"]["image_source"], config["norm_pixel"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/rgu01/Library/CloudStorage/OneDrive-Mälardalensuniversitet/Documents/Programs/scenarionet/metadrive/metadrive/obs/image_obs.py", line 61, in init self.state = np.zeros(self.observation_space.shape, dtype=np.float32 if self.norm_pixel else np.uint8) ^^^^^^^^^^^^^^^^^^^^^^ File "/Users/rgu01/Library/CloudStorage/OneDrive-Mälardalensuniversitet/Documents/Programs/scenarionet/metadrive/metadrive/obs/image_obs.py", line 67, in observation_space sensor_cls = self.config["sensors"][self.image_source][0]


  File "/Users/rgu01/Library/CloudStorage/OneDrive-Mälardalensuniversitet/Documents/Programs/scenarionet/metadrive/metadrive/utils/config.py", line 226, in __getitem__
    self._check_and_raise_key_error(item)
  File "/Users/rgu01/Library/CloudStorage/OneDrive-Mälardalensuniversitet/Documents/Programs/scenarionet/metadrive/metadrive/utils/config.py", line 212, in _check_and_raise_key_error
    raise KeyError(
KeyError: "'main_camera' does not exist in existing config. Please use config.update(...) to update the config. Existing keys: dict_keys(['lidar', 'side_detector', 'lane_line_detector', 'rgb_camera', 'depth_camera'])."
QuanyiLi commented 9 months ago

Do you install from pip? The PR I merged just now should solve this if you are installing from github... Also, Mac with M chips can not do 3D rendering as the OpenGL is deprecated on MacOS

rgu01 commented 9 months ago

Yes, pip install -e . I can run "python -m metadrive.examples.profile_metadrive" with no problem. However, neither "python -m metadrive.examples.drive_in_single_agent_env" nor "python -m metadrive.examples.verify_headless_installation" is working.

QuanyiLi commented 9 months ago

Do you pull the latest main in the metadrive repo? The latest git log message should be " Fix example (#657)" with commit number "c326ae5f6b409ed90d2bcda8b5bc12689c8c03b5"

rgu01 commented 9 months ago

Yes, I pulled the latest code, but I did not run "pip install" again. Now the problem is an exception in "Showcase.py", cannot open the window. The detail is as below:

After running "python -m metadrive.examples.drive_in_single_agent_env", I got [INFO] Environment: MetaDriveEnv [INFO] MetaDrive version: 0.4.2.3 [INFO] Sensors: [lidar: Lidar(), side_detector: SideDetector(), lane_line_detector: LaneLineDetector(), main_camera: MainCamera(1200, 900), dashboard: DashBoard()] [INFO] Render Mode: onscreen [INFO] Horizon (Max steps per agent): None [INFO] Assets version: 0.4.2.3 :ShowBase(warning): Unable to open 'onscreen' window. Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "/Users/rgu01/Library/CloudStorage/OneDrive-Mälardalensuniversitet/Documents/Programs/scenarionet/metadrive/metadrive/examples/drive_in_single_agentenv.py", line 51, in o, = env.reset(seed=21) ^^^^^^^^^^^^^^^^^^ File "/Users/rgu01/Library/CloudStorage/OneDrive-Mälardalensuniversitet/Documents/Programs/scenarionet/metadrive/metadrive/envs/base_env.py", line 517, in reset self.lazy_init() # it only works the first time when reset() is called to avoid the error when render ^^^^^^^^^^^^^^^^ File "/Users/rgu01/Library/CloudStorage/OneDrive-Mälardalensuniversitet/Documents/Programs/scenarionet/metadrive/metadrive/envs/base_env.py", line 409, in lazy_init initialize_engine(self.config) File "/Users/rgu01/Library/CloudStorage/OneDrive-Mälardalensuniversitet/Documents/Programs/scenarionet/metadrive/metadrive/engine/engine_utils.py", line 38, in initialize_engine cls.singleton = cls(env_global_config) ^^^^^^^^^^^^^^^^^^^^^^ File "/Users/rgu01/Library/CloudStorage/OneDrive-Mälardalensuniversitet/Documents/Programs/scenarionet/metadrive/metadrive/engine/base_engine.py", line 55, in init EngineCore.init(self, global_config) File "/Users/rgu01/Library/CloudStorage/OneDrive-Mälardalensuniversitet/Documents/Programs/scenarionet/metadrive/metadrive/engine/core/engine_core.py", line 194, in init super(EngineCore, self).init(windowType=self.mode) File "/Users/rgu01/miniconda3/envs/metadrive/lib/python3.11/site-packages/direct/showbase/ShowBase.py", line 341, in init self.openDefaultWindow(startDirect = False, props=props) File "/Users/rgu01/miniconda3/envs/metadrive/lib/python3.11/site-packages/direct/showbase/ShowBase.py", line 1026, in openDefaultWindow self.openMainWindow(*args, *kw) File "/Users/rgu01/miniconda3/envs/metadrive/lib/python3.11/site-packages/direct/showbase/ShowBase.py", line 1061, in openMainWindow self.openWindow(args, **kw) File "/Users/rgu01/miniconda3/envs/metadrive/lib/python3.11/site-packages/direct/showbase/ShowBase.py", line 806, in openWindow raise Exception('Could not open window.') Exception: Could not open window.

Could it be a MacBook Pro problem?

QuanyiLi commented 9 months ago

Yes. As I said before, Mac with M chips can not do 3D rendering for MetaDrive as OpenGL is deprecated on MacOS

rgu01 commented 9 months ago

Thanks. Is there a way to disable the 3D rendering and keep using the rest of MetaDrive? Now, I simply want to run some examples but have not managed once.

QuanyiLi commented 9 months ago

Of course. You can still use the2D renderer. All examples in our documentation are generated with 2D renderer: https://metadrive-simulator.readthedocs.io/ All examples can run on both colab and local machines. They also show you how to use this 2D renderer as well.

rgu01 commented 9 months ago

Of course. You can still use the2D renderer. All examples in our documentation are generated with 2D renderer: https://metadrive-simulator.readthedocs.io/ All examples can run on both colab and local machines. They also show you how to use this 2D renderer as well.

Perfect. I meant turning on/off the 3D render in your examples, such as python -m metadrive.examples.drive_in_single_agent_env. Anyway, I am running the 2D codes locally on my own laptop. Thanks for the help.