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

Examples are panicking when running in virtualbox #413

Closed
itgenie98 opened this issue Sep 1, 2020 · 8 comments
Closed

Examples are panicking when running in virtualbox #413

itgenie98 opened this issue Sep 1, 2020 · 8 comments
Labels
A-Rendering Drawing game state to the screen C-Startup A crash that occurs when first attempting to run a Bevy app P-Crash A sudden unexpected crash

Comments

@itgenie98
Copy link

Virtualbox 6.1.12
Guest OS: Arch Linux, Kernel 5.8.5
GPU: VMware SVGA II Adapter (VMSVGA)

Steps to reproduce:

  1. use a virtualbox vm with the VMSVGA graphics adapter
  2. install rustup
  3. clone bevy repository (for the examples)
  4. run cargo run --example breakout

Expected behavior:
Running the bevy breakout example

Actual behavior:
Cargo / Rust crashes with following errormessage: (with RUST_BACKTRACE=1)

     Running `target/debug/examples/breakout`
thread 'main' panicked at 'Unable to find a GPU! Make sure you have installed required drivers!', crates/bevy_wgpu/src/wgpu_renderer.rs:28:14
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1076
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1537
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:198
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:217
  10: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:526
  11: rust_begin_unwind
             at src/libstd/panicking.rs:437
  12: core::panicking::panic_fmt
             at src/libcore/panicking.rs:85
  13: core::option::expect_failed
             at src/libcore/option.rs:1261
  14: core::option::Option<T>::expect
             at /rustc/04488afe34512aa4c33566eb16d8c912a3ae04f9/src/libcore/option.rs:344
  15: bevy_wgpu::wgpu_renderer::WgpuRenderer::new::{{closure}}
             at crates/bevy_wgpu/src/wgpu_renderer.rs:22
  16: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/04488afe34512aa4c33566eb16d8c912a3ae04f9/src/libcore/future/mod.rs:78
  17: pollster::block_on
             at /home/itgenie98/.cargo/registry/src/github.com-1ecc6299db9ec823/pollster-0.2.0/src/lib.rs:64
  18: bevy_wgpu::wgpu_render_system
             at crates/bevy_wgpu/src/lib.rs:35
  19: <bevy_wgpu::WgpuPlugin as bevy_app::plugin::Plugin>::build
             at crates/bevy_wgpu/src/lib.rs:22
  20: bevy_app::app_builder::AppBuilder::add_plugin
             at ./crates/bevy_app/src/app_builder.rs:235
  21: <bevy_app::app_builder::AppBuilder as bevy::add_default_plugins::AddDefaultPlugins>::add_default_plugins
             at src/add_default_plugins.rs:33
  22: breakout::main
             at examples/game/breakout.rs:9
  23: std::rt::lang_start::{{closure}}
             at /rustc/04488afe34512aa4c33566eb16d8c912a3ae04f9/src/libstd/rt.rs:67
  24: std::rt::lang_start_internal::{{closure}}
             at src/libstd/rt.rs:52
  25: std::panicking::try::do_call
             at src/libstd/panicking.rs:348
  26: std::panicking::try
             at src/libstd/panicking.rs:325
  27: std::panic::catch_unwind
             at src/libstd/panic.rs:394
  28: std::rt::lang_start_internal
             at src/libstd/rt.rs:51
  29: std::rt::lang_start
             at /rustc/04488afe34512aa4c33566eb16d8c912a3ae04f9/src/libstd/rt.rs:67
  30: main
  31: __libc_start_main
  32: _start
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
@M4SSD35TRUCT10N
Copy link

Seems related to #402. Doesn't work on x86_64 Manjaro XFCE 20.0.3 nor on Raspberry Pi 4B+ with 8GB RAM either. Although it compiles without any problems.

@inodentry
Copy link
Contributor

inodentry commented Sep 1, 2020

Are you sure the virtual machine "gpu" and its driver support Vulkan? I doubt that's the case, because IIRC vulkan support in virtual machines is still very experimental if at all existent.

Your error seems to indicate that this is the case ("cannot find gpu!"); your system does not provide the needed GPU APIs.

Bevy does not support an OpenGL or GLES backend yet, or any sort of software rendering, so you cannot run it if you don't have a GPU and driver that support Vulkan (or dx12 on windows, or metal on mac).

I wouldn't expect bevy to work in a virtual machine at all, at least not yet.

@M4SSD35TRUCT10N
Copy link

M4SSD35TRUCT10N commented Sep 1, 2020

Are you sure the virtual machine "gpu" and its driver support Vulkan? I doubt that's the case, because IIRC vulkan support in virtual machines is still very experimental if at all existent.

Your error seems to indicate that this is the case ("cannot find gpu!"); your system does not provide the needed GPU APIs.

Bevy does not support an OpenGL or GLES backend yet, or any sort of software rendering, so you cannot run it if you don't have a GPU and driver that support Vulkan (or dx12 on windows, or metal on mac).

I wouldn't expect bevy to work in a virtual machine at all, at least not yet.

I do have vulkan-intel driver installed on my Laptop. Currently checking out if it can be or is already loaded. On Raspberry Pi 4B+ it's certainly not available and thus understandable that it doesn't work. But anyway @jamadazi thank you for the hint.

EDIT
My Sandy Bridge CPU/GPU is not supported by the vulkan-intel driver. Which means I can't use it right now at least as long as I didn't add OpenGL support by myself - which is very unlikely at my current Rust skill level.

@Moxinilian Moxinilian added P-Crash A sudden unexpected crash A-Rendering Drawing game state to the screen labels Sep 1, 2020
@mkesper
Copy link

mkesper commented Sep 7, 2020

Is is possible to install mesa-vulkan-drivers? That's what it's called in Debian. Performance will be bad but at least it does run.

@CleanCut
Copy link
Member

@mkesper I've got mesa-vulkan-drivers installed in my Ubuntu 20.04 VM, and it fails with the same "Unable to find a GPU! ..." error. 😢

@mkesper
Copy link

mkesper commented Oct 12, 2020

Sorry, I've no idea then, that was just what helped me on baremetal.

@alice-i-cecile alice-i-cecile added the C-Startup A crash that occurs when first attempting to run a Bevy app label Dec 21, 2021
@code-monad
Copy link

code-monad commented Jan 5, 2022

TL;DR

It's not bevy's fault, this is due to the SVGA driver does not support vulkan right now.

Methods to avoid this issue(currently):

  • Painless: Get a GPU passthrough to your guest & install the proper driver.
  • Software layer: Install a software Vulkan rasterizer, more specifically, lavapipe or the mesa main branch which have merged the lavapipe features. But you'll meet performance issue(quite obviously), and make sure that you're walking on the edge
  • New backend or layer: this might be a hardcore job since we are using wgpu, which may still having issue about running over OpenGLES on Linux, you may implement a software render backend, and it's definetly hard.*sigh*

Although this is a thread from September, but it is still open, and I've ran into the same issue, tried to figure it out with some workaround.

The env I've tried:

  1. WSL2 on Win10/Win11 with a nVidia GPU on host
  • All presentation is through X410(A XServer on Windows)
  • Tried to install the experimental CUDA driver that supports WSL, but with no luck
  1. Archlinux on a VMWare host
  • Same as previous, no WM&DE, just use a XServer on my host machine for more flexible and my personal development habit.
  • Key packages I've installed: mesa, vulkan-swrast, and with an optional vulkan-mesa-layers

And here are several ways about how to make bevy(or more generically, vulkan backend) running under a VM-like environment without hacking the source code of bevy:

1. Try to get a external gpu and passthrough it to you guest machine.

This is the most efficient and painless way to avoid the none gpu issue. You will fell like you are getting the power of the computed units -- everything even cuda works fine.
For about how to configure PCIE passthrough , here are some links about it:

And do make sure you installed the proper driver, check if the dkms module is loaded, vkcube works fine and runnign in a high refresh rate! It's cellarbration time! You can even connect the GPU output ports to external display monitors

But the problem is, GPU is really expensive right now and you need a external GPU with a second PCIE slot to do that, which may only in full-sized boards, no luck for ITX builds and low-end products.

2. Configuring a software Vulkan rasterizer

So we are here, we do not own any other GPUs, or we can't do that, or you just don't want to, whatever the reason is, we need to fix it and get bevy, and other Vulkan applications working on a VM guest.

If you are in Ubuntu/WSL/WSL2, you could try compile the mesa source yourself and install it, or you could just use this PPA: https://launchpad.net/~kisak/+archive/ubuntu/kisak-mesa

If you are in Arch, just install vulkan-swrast after you installing the xf86-video-vmware

The FPS is about half of the hardware solution, you can fell you are back to the 80s while running the breakout exmaple. But hey, anyway we successfully make it running without complains!
*Forget about the single line says WARNING: lavapipe is not a conformant vulkan implementation, testing use only. and do hope yourself lucky all the time.*

*edited 2022/02/28

since gfx-rs/wgpu#1551 was closed maybe this problem can be fixed by updating to the latest wgpu

@mockersf
Copy link
Member

mockersf commented Jan 5, 2022

Bevy has a few examples running in CI using lavapipe, you can check the job here:

run-examples:
runs-on: ubuntu-latest
steps:
- name: Install Bevy dependencies
run: |
sudo apt-get update;
DEBIAN_FRONTEND=noninteractive sudo apt-get install --no-install-recommends -yq \
libasound2-dev libudev-dev;
- name: install xvfb, llvmpipe and lavapipe
run: |
sudo apt-get update -y -qq
sudo add-apt-repository ppa:oibaf/graphics-drivers -y
sudo apt-get update
sudo apt install -y xvfb libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-run-examples-${{ hashFiles('**/Cargo.toml') }}
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Build bevy
run: |
cargo build --no-default-features --features "bevy_dynamic_plugin,bevy_gilrs,bevy_gltf,bevy_winit,render,png,hdr,x11,bevy_ci_testing,trace,trace_chrome"
- name: Run examples
run: |
for example in .github/example-run/*.ron; do
example_name=`basename $example .ron`
echo "running $example_name - "`date`
time CI_TESTING_CONFIG=$example xvfb-run cargo run --example $example_name --no-default-features --features "bevy_dynamic_plugin,bevy_gilrs,bevy_gltf,bevy_winit,render,png,hdr,x11,bevy_ci_testing,trace,trace_chrome"
sleep 10
done
zip traces.zip trace*.json
- name: save traces
uses: actions/upload-artifact@v1
with:
name: example-traces.zip
path: traces.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Startup A crash that occurs when first attempting to run a Bevy app P-Crash A sudden unexpected crash
Projects
None yet
Development

No branches or pull requests

9 participants