microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.32k stars 814 forks source link

Different GPU getting detected inside devcontainer and WSL2 Ubuntu distro #9631

Closed sshaizkhan closed 2 weeks ago

sshaizkhan commented 1 year ago

Version

Microsoft Windows [Version 10.0.22621.1194]

WSL Version

Kernel Version

5.15.79.1

Distro Version

Ubuntu 22.04.1 LTS

Other Software

Docker Desktop (Windows), version 4.16.3 Visual Studio Code :

{  

- Version: 1.75.1 (user setup)
- Commit: 441438abd1ac652551dbe4d408dfcec8a499b8bf
- Date: 2023-02-08T21:32:34.589Z
- Electron: 19.1.9
- Chromium: 102.0.5005.194
- Node.js: 16.14.2
- V8: 10.2.154.23-electron.0
- OS: Windows_NT x64 10.0.22621
- Sandboxed: No

}

with extensions:

Repro Steps

I'm getting different output by running glxinfo -B inside the dev container and installed Ubuntu 22.04 distro in WSL2. The Ubuntu distro is successfully showing the correct output with Device: D3D12 (NVIDIA GeForce GTX 1660 Ti) (0xffffffff) and can run graphic application like meshlab but the devcontainer is showing Device: llvmpipe (LLVM 15.0.6, 256 bits) (0xffffffff) and is even unable to run glxgears on it.

The steps to reproduce this issue atleast on my machine are mentioned below.

I have made a docker image using the below Dockerfile contents:

FROM moveit/moveit2:humble-release

# Setting up packages for devops
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-unauthenticated \
lsb-release \
net-tools \
iputils-ping \
apt-utils \
build-essential \
psmisc \
vim-gtk \
scons \
bison \
flex \
git \
sudo \
keyboard-configuration \
 && rm -rf /var/lib/apt/lists/*

ENV USERNAME bot
RUN adduser --ingroup sudo --disabled-password --gecos "" --shell /bin/bash --home /home/$USERNAME $USERNAME
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
RUN bash -c 'echo $USERNAME:bot | chpasswd'
ENV HOME /home/$USERNAME
USER $USERNAME

RUN rosdep update
RUN sudo apt update
RUN sudo apt dist-upgrade

RUN sudo apt install bash-completion

RUN sudo apt install -y python3-pip
RUN sudo apt install python3-colcon-common-extensions
RUN sudo apt install python3-colcon-mixin
RUN sudo apt install -y ros-humble-rmw-cyclonedds-cpp

RUN sudo apt install python3-vcstool

Build the docker image using the above Dockerfile contents and name it as moveit2:humble.

Once the image is build, create a workspace with the following directory structure, assuming you in /home/$USER path :

 - dev
     - moveit2_ws
        - src
           - devcontainer.env
           - test_folder or whatever name you want to give
               - .devcontainer
                   - devcontainer.json

The content inside devcontainer.json:

{
  "name": "moveit2:humble",
  "image": "moveit2:humble",
  "runArgs": [
    "--cap-add=SYS_PTRACE",
    "--security-opt=seccomp=unconfined",
    "--gpus=all",
    "--device-cgroup-rule=c 189:* rmw",
    "--volume=/dev/bus/usb:/dev/bus/usb:ro",
    "--volume=/dev/input:/dev/input:ro",
    "--volume=/home/shah/.ssh/:/home/bot/.ssh/:ro", // required for open3d visualization
    "--network=host",
    "--privileged",
    "--env-file",
    "../devcontainer.env"
  ],
  "containerEnv": {
    "CONTAINER_NAME": "moveit2",
    "TZ": "America/New_York"
  },
  // Add the IDs of extensions you want installed when the container is created.
  "customizations": {
    "vscode": {
      "extensions": [
        "ms-vscode.cpptools",
        "ms-python.vscode-pylance",
        "ms-python.python",
        "twxs.cmake",
        "ms-vscode.cmake-tools",
        "mutantdino.resourcemonitor",
        "mhutchie.git-graph",
        "grapecity.gc-excelviewer",
        "coenraads.bracket-pair-colorizer",
        "ms-vscode.cpptools-extension-pack"
      ]
    }
  },
  // Use 'postCreateCommand' to run commands after the container is created.
  //"postCreateCommand": "/bin/bash /home/bot/moveit2_ws/src/moveit2_app/.devcontainer/post_create.bash",
  // // Use 'postAttachCommand' to run commands each time you attach to the container.
  //"postAttachCommand": "/bin/bash /home/bot/moveit2_ws/src/moveit2_app/.devcontainer/post_attach.bash",
  // Mount aio_palletizing_app under src/
  "workspaceMount": "source=${localWorkspaceFolder}/../../,target=/home/bot/moveit2_ws/,type=bind,consistency=cached",
  "workspaceFolder": "/home/bot",
  // Connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
  "remoteUser": "bot",
  // See https://code.visualstudio.com/docs/remote/containers-advanced#_specifying-the-default-container-user
"containerUser": "bot"
}

Open visual code inside test_folder or whatever name gave and if you have Dev container extension installed (mentioned above), a pop-up will appear to open the project inside dev container. Once the container is build, open the terminal inside the container and install Mesa Utils using the command sudo apt-get install mesa-utils and run glxinfo -B to see the output.

Expected Behavior

name of display: :0
display: :0  screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: Microsoft Corporation (0xffffffff)
    Device: D3D12 (NVIDIA GeForce GTX 1660 Ti) (0xffffffff)
    Version: 22.2.5
    Accelerated: yes
    Video memory: 14089MB
    Unified memory: no
    Preferred profile: core (0x1)
    Max core profile version: 4.2
    Max compat profile version: 4.2
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.1
OpenGL vendor string: Microsoft Corporation
OpenGL renderer string: D3D12 (NVIDIA GeForce GTX 1660 Ti)
OpenGL core profile version string: 4.2 (Core Profile) Mesa 22.2.5
OpenGL core profile shading language version string: 4.20
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 4.2 (Compatibility Profile) Mesa 22.2.5
OpenGL shading language version string: 4.20
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile

OpenGL ES profile version string: OpenGL ES 3.1 Mesa 22.2.5
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10

Actual Behavior

name of display: :0
display: :0  screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: Mesa/X.org (0xffffffff)
    Device: llvmpipe (LLVM 15.0.6, 256 bits) (0xffffffff)
    Version: 22.2.5
    Accelerated: no
    Video memory: 15835MB
    Unified memory: no
    Preferred profile: core (0x1)
    Max core profile version: 4.5
    Max compat profile version: 4.5
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.2
OpenGL vendor string: Mesa/X.org
OpenGL renderer string: llvmpipe (LLVM 15.0.6, 256 bits)
OpenGL core profile version string: 4.5 (Core Profile) Mesa 22.2.5
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 4.5 (Compatibility Profile) Mesa 22.2.5
OpenGL shading language version string: 4.50
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile

OpenGL ES profile version string: OpenGL ES 3.2 Mesa 22.2.5
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20

Diagnostic Logs

No response

m4renz commented 1 year ago

Has there been any progress made? I'm having the same issue using WSL2 and Ubuntu 20.04 with Docker installed over WSL and not Docker Desktop.

onomatopellan commented 1 year ago

For gpu acceleration and more inside the container follow this: https://github.com/microsoft/wslg/blob/main/samples/container/Containers.md

microsoft-github-policy-service[bot] commented 2 weeks ago

This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.

Thank you!