WSL 2 With NVIDIA Driver Not Utilizing the GPU For ROS Gazebo Simulation

I’ve been testing out the new NVIDIA driver on Windows 10 with WSL 2. I’ve been able to get Docker containers running that utilize the GPU but I’m having issues using the GPU in a Gazebo simulation. I installed ROS Kinetic on Ubuntu 16.04 in WSL 2 with an X Server installed. Executing roslaunch gazebo_ros rubble_world.launch opens a Gazebo simulation but with very poor performance. Task Manager shows very high CPU usage (>90%) but only 2% GPU usage and I’m not even sure if any of that’s from WSL running. Does the NVIDIA driver not work for situations like this yet?

1 Like

Thanks a lot for reporting the issue. We have not tried the ROS Kinetic with Gazego simulation in WSL2 yet.
Wanted quickly to mention that at this point only compute scenarios are supported for GPU within the WSL2.
We will give it a try to repro the issue in-house and will keep you posted.

3 Likes

I can confirm that I am experiencing the same issue as well with ros melodic and noetic launching gazebo within docker. I have WSL Ubuntu 20.04, and able to run ./deviceQuery and the benchmark tool successfully recognizing my GPU.

Quick update on the issue. ROS Kinetic only supported on Ubuntu 16.04. However, there seems to be a bug in GPU implementation on that Ubuntu distro in WSL2 where GPU supported libraries do not get mapped into the containers properly. We are working with Microsoft on debugging this issue. We will keep you posted.

2 Likes

Would it be possible for you to provide the detail steps on what/how ROS distro was installed, how you installed the Gazebo simulator (what ros distro specified) and whether there were any errors in the system logs reported?

2 Likes

Thanks for getting back to me so fast. Honestly if this stuff worked, I’d be tempted to delete my Linux partition on my personal computer for working at home. WSL 2 has seriously impressed me. Thanks for all of your team’s hard work!

I followed the instructions for installing ROS Kinetic base installation on the ROS wiki (http://wiki.ros.org/kinetic/Installation/Ubuntu).

For our project, we need a newer version of Gazebo so I installed Gazebo 9 using the instructions on Gazebo’s tutorial site (http://gazebosim.org/tutorials/?tut=ros_wrapper_versions#UsingaspecificGazeboversionwithROS). I had other packages installed at the time but they shouldn’t have affected running the simulation. I can’t remember if I had any errors that were specific to this test but I’ll try a fresh 16.04 install with the instructions that I wrote the next time I’m on Windows and report back.

I also tried using a docker container with ROS Kinetic and Gazebo 7 (the default version included with ROS Kinetic) on WSL 2 using Nvidia-docker. I tested it with two different X Servers (x410 and VcXsrv) and got the same result on both.

These should be the steps for installing ROS:

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt-get update
sudo apt-get install ros-kinetic-ros-base
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc

Steps for installing Gazebo 9:

sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'
wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
sudo apt-get update
sudo apt-get ros-kinetic-gazebo9*

Launching the simulation:

roslaunch gazebo_ros rubble_world.launch

Using a docker container (you can optionally change the CMD at the end of the Dockerfile to launch rubble_world.launch but it’s not necessary)

git clone https://github.com/facontidavide/ros-docker-gazebo
cd ros-docker-gazebo
docker build -t ros-kinetic-gazebo7 .

Edit launch_docker.sh to use the --gpus tag (replace lines 4 & 5 with the following single line):

docker run --gpus all \

Run the script

 ./launch_docker.sh

Sure thing, here is a log with the step by step of what was attempted to install ros noetic:

$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

$ sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

$ curl -sSL 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xC1CF6E31E6BADE8868B172B4F42ED6FBAB17C654' | sudo apt-key add -

$ sudo apt update

$ sudo apt install ros-noetic-desktop-full

Launching gazebo without docker:

 roslaunch gazebo_ros empty_world.launch

I tried as well launching gazebo from within docker. I have a project docker container with --gpus=all flag turned on, and previously tested on an Ubuntu machine.

Thank you so much again for the timely follow up. Please feel free to reach out if there are any other pieces of information or steps you would like us to try!

Not sure if this helps, I have Ubuntu 20.04 installed on WSL, and the docker container launches with Ubuntu 18.04 (and ros melodic, showing the same issue as the noetic install).

Could you also mention steps to install the right version of Gazebo (the one that you used to install on Ubuntu 20.04)?

The gazebo installation for Ubuntu 20.04 came directly for me with the desktop full installation for ros neotic:

 sudo apt-get install ros-noetic-desktop-full

However if you would like to directly install gazebo with neotic, you can also use:

sudo apt-get install ros-noetic-gazebo-ros

If you would like to know which gazebo version I have with neotic on 20.04:

ranakhalil@Rana-PC:/mnt/c/Users/User$ gazebo --version
Gazebo multi-robot simulator, version 11.0.0
Copyright (C) 2012 Open Source Robotics Foundation.
Released under the Apache 2 License.
http://gazebosim.org


Gazebo multi-robot simulator, version 11.0.0
Copyright (C) 2012 Open Source Robotics Foundation.
Released under the Apache 2 License.
http://gazebosim.org

Please don’t hesitate to reach out if you have any other questions! Thank you so much for the follow up

For the Gazebo simulation on ROS. Did you somehow specified it should pick the GPU for the workload? It doesn’t seem to do so by default. Or did you build a docker container for this workload to force it to run on GPU?

And even if it does, there are unfortunately still some missing pieces in OS to support the GPU acceleration for GUI. You can read more about this here: The Windows Subsystem for Linux BUILD 2020 Summary - Windows Command Line

2 Likes

I didn’t specify that it should use the GPU but I’m pretty sure it uses it by default for at least some of its components. A quick google search found some people wanting to restrict Gazebo to use only the CPU in order to use the GPU for other tasks like TensorFlow. Gazebo also allows for simulating vision-based sensors that would almost certainly require a GPU.

It’s nice that the GUI support is on the roadmap. It’s really cool how much WSL can do already.

2 Likes

Have exactly the same problem as @kaineub and @rana.ae.khalil. When I run glxgears I get frame rate of ~1300 (within a docker container) but when I run Gazebo (and also RViz) I get a frame rate of ~30 (also in a docker container). System information:

  • Windows 10 Version 2004 (OS Build 20190.1000)
  • Kernel version 4.19.121
  • Ubuntu 20.04 (WSL 2)
  • ROS Melodic
  • Nvidia GeForce driver 455.41
  • Gazebo 9.x
  • VcxSrv

WSL 2 is great for our hardware team who work with a lot of windows tools and having that seamless transition between the two is valuable. Thanks for the work, looking forward to the update that will enable GUI’s to run without X server.

2 Likes

Is there any update on this topic? I have the same problem now.

1 Like

hello,I got same problem.
Is there any update on this topic?

ubuntu18.04
ROS-melodic
gazebo9

GPU is RTX2070

Hello there,

I also encountered the same issue.

winver: Version Dev (Build 21343.1000)
WSL2: Ubuntu 20.04 with ROS Noetic.
nvcc --version:

Cuda compilation tools, release 11.0, V11.0.221
Build cuda_11.0_bu.TC445_37.28845127_0

nvidia-smi.exe:

NVIDIA-SMI 470.14 Driver Version: 470.14 CUDA Version: 11.3

RTX 2060

Steps to reproduce:

sudo sh -c ‘echo “deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main” > /etc/apt/sources.list.d/ros-latest.list’

$ sudo apt-key adv --keyserver ‘hkp://keyserver.ubuntu.com:80’ --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
$ sudo apt update
$ sudo apt install ros-noetic-desktop-full
$ sudo apt install ros-noetic-velodyne-gazebo-plugins
$ roslaunch velodyne_description example.launch gpu:=true

Try installing these PPA’s
ppa:kisak/kisak-mesa
ppa:oibaf/graphics-drivers

and restart wsl2 and try again
it worked for me.

Same problem for me on ROS Noetic and WSL 2.

Windows 11 Version 21H2 (Build 22000.469)
NVIDIA-SMI 510.00   Driver Version: 510.06  CUDA Version: 11.6

After that I couldn’t open any GUI apps from WSL anymore

When I try the first command it show:
Cannot add PPA: ‘ppa:~kisak/ubuntu/kisak-mesa’.
The user named ‘~kisak’ has no PPA named ‘ubuntu/kisak-mesa’
Please choose from the following available PPAs:

  • ‘kisak-mesa’: kisak-mesa fresh
  • ‘kisak-mesa-build-deps’: kisak-mesa build dependencies
  • ‘steamvr’: SteamVR Experimental Graphics
  • ‘steamvr4pk’: SteamVR + Padoka
  • ‘turtle’: kisak-mesa stable