-
Notifications
You must be signed in to change notification settings - Fork 290
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
Gazebo in Windows Docker cannot use Nvidia GPU, falls back to using CPU. #2595
Comments
Sorry if I missed anything, but I don't really fully know all of this. If more information is needed, please let me know, and I will try my best to provide them. Tried using Gazebo garden as suggested in: #920 |
llvmpipe Is already used in glxinfo, that suggests that there is something going on independently from Gazebo. Can you run any program at all that uses the GPU in WSL2? Note that docker could play a role here, so you may want to start outside docker and only in the WSL2 instance, and only if it works move in docker. |
Nothing can access the GPU in this setting. |
Wait hang on this is a little different, lemme try kisak MESA. |
Well, kisak MESA is generally considered to be the solution, but it does not work here. |
Sorry, can you run |
I don't have an integrated GPU, so I don't think that's the case. By outside docker do you mean the wsl2 just like above? |
Yes, I would first try to get everything working in wsl2, and then I would add the additional docker complexity later. Anyhow, a few interesting documentation entry points: |
Yeah I would be interested in seeing all this run outside docker on your WSL2 instance. I'm not aware of anyone running on WSL2 with docker for gazebo simulation. I sorta view WSL2 as it's own form of a "docker interactive linux shell for windows". Getting true full GPU enablement in docker is already a pain and occasionally breaks with mismatched drivers and runtimes on native as is. Unless you work for docker and your job relies on you making it work in docker, I would never suggest it if your main objective is to run a simulator/simulation. I almost view it as running Docker CE instance in an existing Docker CE. Also appears that GPU paravirtulization in WSL2 might only be supported from docker desktop from some google searches and the official docker documentation on it. Docker does not official state support for Docker CE with GPU paravirtualization on WSL2. |
Although if you are really deadset after testing it on "native WSL2" to use docker maybe look at this from microsoft, looks like there might be a way: https://learn.microsoft.com/en-us/windows/wsl/tutorials/gpu-compute |
Also the Intel i7-11700 that you are showing has a UHD 750 integrated GPU, you will probably need to specify what GPU you want to use regardless: https://learn.microsoft.com/en-us/windows/wsl/tutorials/gpu-compute#multiple-gpus |
If that is the case, |
Interesting from that link you shared, it says:
|
@toenails6 let us know when you get a chance to test that so we can close this issue if it's just telling WSL what GPU it needs. |
Hmm, that's a lot of info, I'll have to read through that later, but anyhow, the following is from
Directly on WSL2. |
Side note, my incentive behind all this is just so that I can run ROS2-Gazebo stuff for RL on windows (preferably using docker) without having to dual boot. I see someone reportedly succeeding with ros-humble-ros-gzgarden in one of the Github posts mentioned above, so I thought to gives this some more chances. Right now it seems, even if it has a chance of working, its reliability is very much up to questioning, as any small changes or updates seem to break things easily. I personally feel like it would be very niche to have ROS2-Gazebo runnable on either WSL2 or docker on windows, and it has been many years. I'm not too much of an expert in different systems, but I would say this is a very good functionality to say the least. Is it true that this just simply cannot work? |
If this really cannot work that way, I'll just go back to dual booting and leave this post as a warning to others who would attempt to do ROS2-Gazebo on Windows Docker. . |
And to clarify, just in case of misunderstanding I'm not trying to run Docker inside WSL2. |
I don't know what to think here, have I inadvertently succeeded without knowing it was a success? |
I guess I'm confused as to why use docker at all if you are wanting to do RL research why not just do it all native in WSL2? Also looks like it's "running" maybe stress test it with a more difficult world? Like depot world? |
The mentioned GitHub post describes how to use docker to containerize applications inside WSLg, which is different from my situation.
so it likely attempts to use Nvidia, but fails due to some reasons and then falls back to using CPU for rendering. |
What is your Dockerfile now? The zink error is there even for non-Docker WSLg, so I do not think it is relevant. |
I am currently not using Kisak MESA:
|
I am not sure what you meant here, the section "Containerized applications access to the vGPU" in https://github.com/microsoft/wslg/blob/main/samples%2Fcontainer%2FContainers.md describes how to ensure that a docker process uses the physical GPU, how is this different from your use case? |
Are you mapping the directories and setting LD_LIBRARY_PATH=/usr/lib/wsl/lib as documented in the wslg container docs? |
That GitHub post describes the use of containers within WSLg. I am trying to run Docker directly on windows, and Docker Desktop on Windows uses WSL2 as its engine. That first step of WSL2 correctly accessing the GPU is my problem. |
These docker build and run commands are obviously linux commands, not windows commands. |
To clarify again: My problem is trying to get Docker images, which use WSL2 as their engines, to have a vGPU correctly from windows. |
And you tried? https://docs.docker.com/desktop/gpu/ If it's a docker GPU to WSL2 issue that sounds like a problem outside of Gazebo (more a problem with docker, windows and NVidia not playing nicely). Considering it works without that on "native WSL2" I'm leaning towards this being an unsupported edge case. |
Right now it does not work with native WSL2 either. |
I just wanted to give this a shot, but it seems that I have to fall back to dual boot. |
Or maybe weigh just running it in WSL2 without Docker Desktop. |
I have tried it, and I did put some results above. |
The Nvidia forum mentioned above used WSL2, and they have the same problems. |
Sorry, there is something I am missing. In #2595 (comment) you report that the output for "glxinfo" in the "OpenGL renderer string" reported the use of d3d12, that is why I assumed the problem with WSL without docker) was solved, and you were trying to get it working on Docker. Now instead (still with WSL with no Docker) glxinfo -B reports the use of llvmpipe (i.e. software rendering), did you changed something in your system? |
Hmm, there was actually something I changed. I stopped using Kisak MESA because Kisak MESA does not quite work either. |
I would first focus on making sure that glxinfo -B lists "OpenGL renderer string: D3D12 (NVIDIA GeForce RTX 3060)". Once that works, there is hope GPU will work, otherwise not. However if you are on Ubuntu 24.04 d3d12 provide by default mesa should work fine. Are you sure that you do not have anything strange setbin your environment variables such as LIBGL_ALWAYS_SOFTWARE=1? If you are in doubt and you can, it make be an option to reinstall the Ubuntu 24.04 WSL image to start from a clean slate. |
Thank you guys for all the help, the commands and packages you've referred to were incredibly useful! |
The following Solution worked for me. Problem descriptionAbout a week ago, I started using Gazebo Harmonic and had the same problem: It won't use the Nvidia Geforce GPU (in my case, GTX 1050), and the load was on the CPU during the rendering. I also tested the dual-boot solution. It gave me better FPS, but the problem remained the same as before, and all load was on the CPU, so I finally decided to go back to Ubuntu 24.04 based on WSL2. My Solution (Especially for those who should or want to use Windows)before starting, I should mention that I tested Gazebo Harmonic and Gazebo Fortress using both Windows WSL2, dual-booted Ubuntu (both Jammy-22.04 and Noble 24.04 ), and also Windows binary packages provided by Conda and Conda-forge.
Solution Steps
|
@samanipour almost same environment with you but not work for me. (win11-wls2 with ubuntu 24.04, and gazebo Fortress, but with gpu laptop-4070), exactly following your steps, it crashed. |
Are you using Docker or vanilla WSL2? |
WSL2 in win11(23H2)
However, the simulation becomes good for a while and stuck for another, which may be another issue. |
This solved my problem using gazebo in WSL2. |
Thanks for sharing, but just to clarify this issue was tracking problems on running Gazebo with NVIDIA GPU with Docker on WSL2, not running Gazebo with GPU acceleeration on WSL2 . |
This did not solve the problem regarding usage of Docker, sadly. |
This solution is feasible! |
Any one was able to find a solution for this setup inside Docker? |
Environment
No output
host.docker.internal:0.0
root 635 0.0 0.0 3956 2020 pts/0 S+ 03:25 0:00 grep --color=auto Xorg
env: ‘X’: No such file or directory
~/.gz/rendering
env: ‘X’: No such file or directory
Description
Gazebo process should show up in nvidia-smi, and CPU usage should not be so high.
There should not be any errors or warnings when launching Gazebo.
The following errors show up.
nvidia-smi does not show Gazebo process when Gazebo is active.
Steps to reproduce
docker run -it --privileged --name DELTA --gpus all ros2stable
ros2 launch ros_gz_sim gz_sim.launch.py gz_args:=empty.sdf
Output
My docker file:
The text was updated successfully, but these errors were encountered: