scottyhardy / docker-wine

Docker image that includes Wine and Winetricks for running Windows applications on Linux and macOS
MIT License
884 stars 152 forks source link

Graphical application fails #101

Open dershow opened 3 years ago

dershow commented 3 years ago

Describe the bug I'm using an Intel based Mac. If I run a test with notepad then I can get docker-wine to open XQuartz as expected. But, if I try a more graphics intensive application, I get an error.

To Reproduce Steps to reproduce the behavior: I've been trying to run LAStools, which allows viewing of LiDAR data, and can run in Wine. But, when I try to run it with docker-wine it fails:

./docker-wine --volume="Downloads/LAStools:/mnt/mydata" wine /mnt/mydata/bin/lasview.exe -i /mnt/mydata/data/france.laz latest: Pulling from scottyhardy/docker-wine Digest: sha256:580121f5096660c0d699768be51109bdc4d69377794619bae5f3c6247ad1b72e Status: Image is up to date for scottyhardy/docker-wine:latest docker.io/scottyhardy/docker-wine:latest libGL error: No matching fbConfigs or visuals found libGL error: failed to load driver: swrast X Error of failed request: GLXBadContext Major opcode of failed request: 149 (GLX) Minor opcode of failed request: 6 (X_GLXIsDirect) Serial number of failed request: 174 Current serial number in output stream: 173

Expected behavior It should open the viewer with the sample data file.

Desktop (please complete the following information):

Additional context Add any other context about the problem here. I did come across these that all seem related to this problem:

https://github.com/huan/docker-wechat/issues/50 https://github.com/scottyhardy/docker-wine/issues/57 https://askubuntu.com/questions/834254/steam-libgl-error-no-matching-fbconfigs-or-visuals-found-libgl-error-failed-t https://bbs.archlinux.org/viewtopic.php?id=244575

gluckzhang commented 3 years ago

Hi @dershow ,

I encountered a similar issue recently. On my desktop, it was caused by the driver of Nvidia. FYI, I just find a slightly better solution than my previous proposal in #57

  1. Install The NVIDIA Container Toolkit
    # Setup the stable repository and the GPG key
    distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
    && curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - \
    && curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
    # Install the nvidia-docker2
    sudo apt-get update
    sudo apt-get install -y nvidia-docker2
    # Restart the docker service
    sudo systemctl restart docker

This can save you some time in tuning the extra arguments when running docker-wine. To test whether the installation works, you can run: sudo docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi, which should output some information about your nvidia card.

  1. Adjust your docker-wine script, add the following part into this elif branch
        # Ignore some warnings
        add_run_arg --env="NO_AT_BRIDGE=1"
        # Be default use win32 architecture
        add_run_arg --env="WINEARCH=win32"
        # Extra args for Nvidia
        add_run_arg --gpus=all
        add_run_arg --env="NVIDIA_DRIVER_CAPABILITIES=all"

    The last two add_run_arg are the key to make the GPU work in a container. Hopefully, this can also fix your issue. Good luck!

Ref: [1] https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#setting-up-nvidia-container-toolkit [2] https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/user-guide.html#driver-capabilities

dershow commented 3 years ago

Thanks. If I understand correctly both of your suggestions involve changes to the host, rather than to the docker container. They are both for running docker on Linux, but I'm trying to run from a Mac, so any drivers, and paths to drivers, are different.

gluckzhang commented 3 years ago

Hi @dershow , that's very true. I didn't notice that you were running a MacOS. Then my solution may not be helpful for you. Sorry about that. But I assume you also need to adjust some configurations on the host. Good luck!

johncadengo commented 3 years ago

@gluckzhang I'm trying your settings out, since I'm using linux. I'm wondering, does the GPU acceleration work in RDP mode? Does it work for the default window manager, or is there something I have to do to enable that?

gluckzhang commented 3 years ago

Hi @johncadengo , I haven't tried it in RDP mode yet. It directly works with my GNOME environment. The script can automatically detect X11 configurations for the container (such as add_x11_key ()). I also added the following line to the script:

add_run_arg --volume="/tmp/.X11-unix:/tmp/.X11-unix:ro"