Skip to content
This repository has been archived by the owner on Mar 23, 2020. It is now read-only.

RVIZ usage with the docker image #6

Open
jabrena opened this issue Jun 20, 2017 · 24 comments
Open

RVIZ usage with the docker image #6

jabrena opened this issue Jun 20, 2017 · 24 comments

Comments

@jabrena
Copy link

jabrena commented Jun 20, 2017

Hi,

I am thinking to use this Dockerfile to do some tests with ROS and my question is if I run the docker image, it is possible to use some tool to see RVIZ.

Sorry if the question is from a beginner.

Many thanks in advance.

Juan Antonio

@jabrena jabrena changed the title RVIZ RVIZ usage with the docker image Jun 20, 2017
@diegoferigo
Copy link
Owner

Hello @jabrena, I missed this issue for some reason. Yes you can use RVIZ with this image, and for some initial tests the most simple steps are:

$ XSOCK=/tmp/.X11-unix
$ XAUTH=/tmp/.docker.xauth

$ touch $XAUTH
$ xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -

$ docker run -i -t --rm \
	     -v $XSOCK:$XSOCK:rw \
	     -v $XAUTH:$XAUTH:rw \
	     -e XAUTHORITY=${XAUTH} \
	     -e DISPLAY \
	     --name ros \
	     diegoferigo/ros \
	     bash

And then, from within the container:

# roscore &
# rviz 

For more advanced tests you can mount some host folders as volumes, set a runtime user instead of using root, use a docker-compose system etc. You can have a look to my Development container to have hints on most advanced usage.

@diegoferigo
Copy link
Owner

No response. Closing.

@subhash
Copy link

subhash commented Mar 9, 2018

I tried these steps on a new container created from your Dockerfile. rviz fails with the following error:

root@6a11901bf194:/# rviz
[ INFO] [1520568098.984444569]: rviz version 1.12.15
[ INFO] [1520568098.984564646]: compiled against Qt version 5.5.1
[ INFO] [1520568098.984603196]: compiled against OGRE version 1.9.0 (Ghadamon)
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
Could not initialize OpenGL for RasterGLSurface, reverting to RasterSurface.
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
Segmentation fault (core dumped)

I am on Ubuntu 16.04

root@6a11901bf194:/# uname -a
Linux 6a11901bf194 4.13.0-32-generic autowarefoundation/autoware#35~16.04.1-Ubuntu SMP Thu Jan 25 10:13:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

@diegoferigo
Copy link
Owner

@subhash I finally found some time to look into this. Do you have an NVidia GPU?

@subhash
Copy link

subhash commented Mar 28, 2018 via email

@diegoferigo
Copy link
Owner

diegoferigo commented Mar 28, 2018

I had a discussion at robotology/icub-main#501 (comment) just few days ago. Nvidia GPUs need a configured docker-nvidia and the following lines added to the image:

# nvidia-docker hooks
LABEL com.nvidia.volumes.needed="nvidia_driver"
ENV PATH /usr/local/nvidia/bin:${PATH}
ENV LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64:${LD_LIBRARY_PATH}

I might consider adding them as default to my images in order to provide an out-of-the-box working setup even on Nvidia. From the user side, however, nvidia-docker will always be necessary.

@mpkuse
Copy link

mpkuse commented Oct 9, 2018

I installed ros-kinetic on tensorflow base image on docker. I cannot seem to get rviz working on the docker.

oot@9406b6e22641:/notebooks# rviz
[ INFO] [1539057258.243957164]: rviz version 1.12.16
[ INFO] [1539057258.244021049]: compiled against Qt version 5.5.1
[ INFO] [1539057258.244042608]: compiled against OGRE version 1.9.0 (Ghadamon)
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
Could not initialize OpenGL for RasterGLSurface, reverting to RasterSurface.
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
Segmentation fault (core dumped)

Although I can run other ros gui applications on docker like rqt_image. How can this be fixed?
Here is my docker image : https://hub.docker.com/r/mpkuse/kusevisionkit/

@KetkiChaudhary
Copy link

Hi,

I am trying to run rviz on autoware docker. I get the following error:

[ INFO] [1539583851.181537990]: rviz version 1.12.16
[ INFO] [1539583851.181578002]: compiled against Qt version 5.5.1
[ INFO] [1539583851.181587881]: compiled against OGRE version 1.9.0 (Ghadamon)
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
Could not initialize OpenGL for RasterGLSurface, reverting to RasterSurface.
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
/home/autoware/Autoware/ros/src/util/packages/runtime_manager/../../../.config/rviz/cmd.sh: line 44: 2362 Segmentation fault (core dumped) rosrun rviz rviz

I am using Ubuntu 16.04 and have Nvidia 1080.

@hristo-vrigazov
Copy link

+1. Getting the same with Ubuntu 16.04 and Nvidia Geforce GTX 1080

@saikishor
Copy link

I am also having the similar issue on my dockers

@hgrw
Copy link

hgrw commented Oct 26, 2018

+1, I'm having the same problem. I changed the dockerfile to use cudagl instead of opengl but it didn't solve the problem

@yuqli
Copy link

yuqli commented Nov 7, 2018

+1, I have the same problem. Cannot get rviz running in a docker environment with autoware. Without docker rviz runs fine.

@mpkuse
Copy link

mpkuse commented Nov 8, 2018

one thing I did is:

  • roscore on container
  • set ROS_MASTER on host
  • set /etc/hosts files in both host and docker and make sure from each you can ping to another
  • verify that messages can be published from container and received at host (https://github.com/mpkuse/docker_ros_test).
  • run rviz on host (using roscore from container)

This seems to work well for me as an alternate way.

@diegoferigo
Copy link
Owner

diegoferigo commented Nov 9, 2018

When I see this error:

libGL error: failed to load driver: swrast

Usually it means that the GPU access was not configured properly. OpenGL applications have always been tricky with Nvidia, but thanks to their amazing work and their new docker runtime everything should run smooth when coupled with nvidia-docker 2.0.

@mpkuse @KetkiChaudhary @hristo-vrigazov @saikishor @hroachewilson @yuqli What's yours system configuration? I suggest you to do tests with minimal images and then add other piece of software on top of it.

I have a XPS 15 with a GeForce GTX 1050 Mobile. My OS is Ubuntu 18.04 configured with bumblebee / bbswitch / optirun. This allows me to have the GPU turned off by default and turning it on only for selected processes (or containers).

I just updated my ROS image to melodic and added the support of nvidia-docker 2.0, can you please try it out? You can follow the updated README. With and without the Nvidia GPU enabled, on my setup RViz works as expected. Within the same container I tried to execute in background roscore first, and then rviz.

@yuqli
Copy link

yuqli commented Nov 12, 2018

@diegoferigo Thanks for the response.

My system configuration :

  1. Dell G7 7800 with a GeForce GTX 1060
  2. OS is Ubuntu 16.04
  3. ROS image is kinetic, but I uninstalled it.

I suspect the problem is I used nvidia-docker instead of a nvidia-docker-2.0, as I seem to see it somewhere about this issue. I have uninstalled everything and will try using nvidia-docker 2.0.

On another note, the demo tutorial on autoware homepage seems to instruct install nvidia-docker 1.0. I'll update when I figured out if this is indeed the issue.

@yuqli
Copy link

yuqli commented Nov 12, 2018

I was wrong. The instructions on autoware homepage let us install NVIDIA Docker: 2.0.3

@diegoferigo
Copy link
Owner

diegoferigo commented Nov 12, 2018

Do the non-opengl GUIs work for you @yuqli? Such as rqt? I don't have any experience with autoware.

@yuqli
Copy link

yuqli commented Nov 12, 2018

Hi @diegoferigo, sorry I later realized this thread is not about autoware. Thanks for the reply!

So the root problem seems to be nvidia-docker2 does not have OpenGL installed automatically inside it, and I found this thread to be very helpful regarding running rviz in autoware docker image. Other non-autoware images might have some useful insights from that thread too...

Here is a revised Dockerfile authored by someone else. When I figured out what that is doing I'll update here again :)

@moucrob
Copy link

moucrob commented Jan 24, 2019

Nvidia GPUs need a configured docker-nvidia and the following lines added to the image:

# nvidia-docker hooks
LABEL com.nvidia.volumes.needed="nvidia_driver"
ENV PATH /usr/local/nvidia/bin:${PATH}
ENV LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64:${LD_LIBRARY_PATH}

Hi, I know nothing about docker internals even though I'm programming inside a container for monthes now. @diegoferigo How could I add your lines to the dockerfile ruling the image please?
I did found this but I prefer not to try, unless I get a way to look at the lines written in that file... Should I trust it? Do those lines are to be written from a system host shell or from the docker shell itself?

PS : I do already have installed docker-ce=5:18.09.1~3-0~ubuntu-xenial and nvidia-docker-2.0 into the system host embedding an geforce 1080

Regards

@diegoferigo
Copy link
Owner

@moucrob You need to get the Dockerfile of your image, append at the bottom those lines, and regenerate the image using docker build (append --help to get all the options). In this way, you generate a new local image that includes your modification.

Be aware that if you want nvidia support, the base image should not be ubuntu but 1.0-glvnd-runtime-ubuntu18.04. I maintain a very simple example in https://github.com/diegoferigo/devenv.

@guru-florida
Copy link

I had to add the --runtime=nvidia to the docker run command and it worked!!

I also added the LABEL/ENV stuff and derived the image from cudagl as well, and installed nvidia-docker2 on the host.

@diegoferigo
Copy link
Owner

@guru-florida Few things changed (again) in the Docker + Nvidia setup. Docker, starting from 19.03, natively supports nvidia GPUs. You don't need anymore the runtime (even though that method is still working and necessary in few edge cases) being substituted with the container toolkit. Have a look to the upstream installation procedure for more details.

@guru-florida
Copy link

@diegoferigo Thanks for replying. Yes, I saw that >19 has built-in support. I am on Docker thru apt from Ubuntu 19. I could have upgraded myself, but I wont be the only one using my docker image so wanted to keep compatible with D<19.

@diegoferigo
Copy link
Owner

I see 👍 Consider though that I still did not see any image which compatibility has been broken by the latest docker update.

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

No branches or pull requests