ros-visualization / rviz

ROS 3D Robot Visualizer
BSD 3-Clause "New" or "Revised" License
849 stars 463 forks source link

Panels fail to render in docker. #1842

Closed miraculin1 closed 1 week ago

miraculin1 commented 1 week ago

Issue

update: Sometimes the panels work as expected, about 1 works out 6 attempt. I've tested with virtualbox, same problem, so I guess this is problem about Qt.

The pics attached below show the problem visually: Screenshot From 2024-11-17 18-37-25 Screenshot From 2024-11-17 18-36-29

Reproduce

I'm running osrf/ros:noetic-desktop-full in docker. After installed nvidia-container-toolkit and run with below script:

docker run -it \
  --gpus all \
  --name $1 \
  --device=/dev/dri:/dev/dri \
  --network=host --ipc=host \
  -v /tmp/.X11-unix:/tmp/.X11-unix \
  -e DISPLAY=$DISPLAY \
  --env="QT_X11_NO_MITSHM=1" \
  --env="NVIDIA_DRIVER_CAPABILITIERS=all" \
  --env="NVIDIA_VISABLE_DEVICES=all" \
  --device /dev:/dev \
  --privileged \
  -v ./mnt:/workspace \
  -e "TERM=xterm-256color" \
  --ulimit nofile=1024:524288 \
  noetic_dev:latest

Then run xhost +local: in host to enable docker's gui to display in host.

Finally run below command in docker cause the problem.

roscore & rviz

I've tried gazebo, gimp and glxgear in docker. They worked well.

Your environment

rhaschke commented 1 week ago

I'm wondering why you use an nvidia container when your device is an AMD GPU.

miraculin1 commented 1 week ago

I'm wondering why you use an nvidia container when your device is an AMD GPU.

Thanks for replying, My laptop have a amdcpu integrate gpu, and a dedicated nvidia gpu. I use nvidia-container for cuda containers.

$ lspci | grep VGA
01:00.0 VGA compatible controller: NVIDIA Corporation GA106M [GeForce RTX 3060 Mobile / Max-Q] (rev a1)
06:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Cezanne [Radeon Vega Series / Radeon Vega Mobile Series] (rev c5)

Could this be a problem?

update: Also, I'm running rviz as root user, linux kernel version is 6.11.7-amd64, dynamic graphic mode. Could the kernel version cause the problem? I've also tried to install ROS and rviz from a clean ubuntu 20.04 docker image, get the same problem.

miraculin1 commented 1 week ago

[Solved] Oh, by adding an user that has same UID GID as host system user in Dockerfile, and run rviz as that new user in docker solve this problem.

Docker file:

ARG USERNAME=ros
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN groupadd --gid $USER_GID $USERNAME \
  && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
  && mkdir /home/$USERNAME/.config && chown $USER_UID:$USER_GID /home/$USERNAME/.config

RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
  &&chmod 0440 /etc/sudoers.d/$USERNAME
tsukione commented 1 week ago

[Solved] Oh, by adding an user that has same UID GID as host system user in Dockerfile, and run rviz as that new user in docker solve this problem.

Docker file:

ARG USERNAME=ros
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN groupadd --gid $USER_GID $USERNAME \
  && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
  && mkdir /home/$USERNAME/.config && chown $USER_UID:$USER_GID /home/$USERNAME/.config

RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
  &&chmod 0440 /etc/sudoers.d/$USERNAME

saddly, it not working, is there any idea

miraculin1 commented 1 week ago

Hi, have you logged in with the new user, and run rviz as new user?