microsoft / wslg

Enabling the Windows Subsystem for Linux to include support for Wayland and X server related scenarios
MIT License
10.22k stars 305 forks source link

Cannot run Linux GUI apps in windows: Error: cannot open display: :0 #880

Closed ajkelsey closed 1 year ago

ajkelsey commented 2 years ago

Windows build number:

Microsoft Windows [Version 10.0.22621.674]

Your Distribution version:

Kali Release: 2022.3

Your WSL versions:

WSL version: 0.70.4.0 Kernel version: 5.15.68.1 WSLg version: 1.0.45 MSRDC version: 1.2.3575 Direct3D version: 1.606.4 DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp Windows version: 10.0.22621.674

Steps to reproduce:

Attempt to run a GUI app from WSL.

WSL logs:

pulseaudio.log stderr.log weston.log

WSL dumps:

No response

Expected behavior:

I expected GUI apps to open in Windows.

Actual behavior:

It didn't open. Received:

Error: cannot open display: :0

crramirez commented 2 years ago

Check this troubleshooting: https://github.com/microsoft/wslg/wiki/Diagnosing-%22cannot-open-display%22-type-issues-with-WSLg

ajkelsey commented 2 years ago

That's how I wound up here. 😁

I will say that /tmp/.X11-unix appears to be a hard link and not a soft link. It does not contain X0 either. If I am running Win-KeX, it will show X1.

drwxrwxrwt 2 root root 40 Oct 28 11:22 .X11-unix

crramirez commented 2 years ago

Win-KeX starts its Xserver, so let's keep it out of the equation.

your issue looks like this: https://github.com/microsoft/wslg/issues/844 or https://github.com/microsoft/wslg/issues/853

Check the troubleshooting there if you see something in the dumps.

You can also try a clean Kali installation before running Win-KeX to see if it is creating something in .X11-unix

ajkelsey commented 2 years ago

So #844 appears to be an issue with running multiple distros and systemd. I am running systemd, but only one distro. Plus, it is said to be resolved by a WSL update. I am running the latest version of WSL.

853 suggests disabling my display device which I am not going to attempt.

Do you happen to know how to install a second instance of Kali? It looks like I need a tar ball, but I don't see one offered by Kali.

ajkelsey commented 2 years ago

Ok. I disabled systemd and that was the problem. The lastest WSL did not resolve that issue for me.

crramirez commented 2 years ago

So #844 appears to be an issue with running multiple distros and systemd. I am running systemd, but only one distro. Plus, it is said to be resolved by a WSL update. I am running the latest version of WSL.

853 suggests disabling my display device which I am not going to attempt.

Do you happen to know how to install a second instance of Kali? It looks like I need a tar ball, but I don't see one offered by Kali.

To install another instance you need to wsl --export ... your current one, and import it again with another name and path.

jimthedj65 commented 2 years ago

I upgraded to Windows 11 today and when I activated systemd in wsl ubuntu 20.04 it broke wslg giving an error of cant connect to display:0 and when I disabled it again in my /etc/wsl.conf it worked again. It's been a long day of testing all this as I come from a Linux background and haven't looked at windows in years.

I will post my setup details in the morning. Thanks to all the many posts I patiently trawled to come to my conclusion 11 hours into my upgrade lol.

crramirez commented 2 years ago

@jimthedj65 test with this version: https://github.com/microsoft/WSL/releases/tag/0.70.8

jimthedj65 commented 2 years ago

@jimthedj65 test with this version: https://github.com/microsoft/WSL/releases/tag/0.70.8

thanks for the response, I ran the install for 0.70.8 and activated systemd and a slight improvement.

Nvidia-smi is recognised

error when running a X session [1196:1196:1109/220605.372613:ERROR:ozone_platform_x11.cc(239)] Missing X server or $DISPLAY [1196:1196:1109/220605.373167:ERROR:env.cc(255)] The platform failed to initialize. Exiting.

WSL version: 0.70.8.0 Kernel version: 5.15.74.2 WSLg version: 1.0.47 MSRDC version: 1.2.3575 Direct3D version: 1.606.4 DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp Windows version: 10.0.22623.885

cat /mnt/wslg/versions.txt WSLg ( x86_64 ): 1.0.47+Branch.main.Sha.77aa1e2f49e1253cde9ceb9124ca0873eb3eadf2 Mariner: VERSION="2.0.20221010" DirectX-Headers: mesa: pulseaudio: 2f0f0b8c3872780f15e275fc12899f4564f01bd5 FreeRDP: c574044a10003e50453acb4cf42801c5833fb572 weston: e7e91e17f370702f386c843cf9014cc4bcef4179

echo $DISPLAY :0

ls -la /tmp/.X11-unix total 4 drwxrwxrwt 2 root root 40 Nov 9 22:09 . drwxrwxrwt 27 root root 4096 Nov 9 22:09 ..

weston.log

Again when I disable systemd in wsl.conf it works again Ubuntu 22.04

hope it helps

jimthedj65 commented 2 years ago

result after deactivating systemd isan X sessions starts again. $ls -la /tmp/.X11-unix/ total 4 drwxrwxrwx 2 root root 60 Nov 9 22:16 . drwxrwxrwt 27 root root 4096 Nov 9 22:17 .. srwxrwxrwx 1 james james 0 Nov 9 22:16 X0

jimthedj65 commented 2 years ago

I noticed that inxi -G was showing that I had no renderer installed and decided to rebuild my 21.04 and its now running chrome with hardware acceleration and no longer broken.

Looks like a few rabbit holes with X breaking here and there.

OpenGL: renderer: D3D12 (NVIDIA GeForce RTX 3080 Ti) v: 3.3 Mesa 21.2.6 Happy Days

crramirez commented 2 years ago

I noticed that inxi -G was showing that I had no renderer installed and decided to rebuild my 21.04 and its now running chrome with hardware acceleration and no longer broken.

Looks like a few rabbit holes with X breaking here and there.

OpenGL: renderer: D3D12 (NVIDIA GeForce RTX 3080 Ti) v: 3.3 Mesa 21.2.6 Happy Days

What did you rebuild? The kernel? mesa?

ajkelsey commented 2 years ago

No improvement for me with 0.70.8.

jimthedj65 commented 2 years ago

I noticed that inxi -G was showing that I had no renderer installed and decided to rebuild my 21.04 and its now running chrome with hardware acceleration and no longer broken. Looks like a few rabbit holes with X breaking here and there. OpenGL: renderer: D3D12 (NVIDIA GeForce RTX 3080 Ti) v: 3.3 Mesa 21.2.6 Happy Days

What did you rebuild? The kernel? mesa?

Hi crramirez,

I scrubbed everything and went into the Microsoft store and downloaded the Ubuntu 20.04 (removing all other versions) and then carefully looked at all the communication out there between Nvidia, Ubuntu, Microsoft and realised there are a number of conflicts. I think previously I had installed the Nvidia drivers as I wasn't getting the nvidia-smi, then realised on the rebuild that nvidia-smi lived in /usr/lib/wsl/lib etc

The only issue I now have is google-chrome build is inconsistently picking up hardware acceleration and then defaulting back to software acceleration through chrome://gpu . I think this is a misreport leading to a false - positive and it is actually running (I do get an error output on the screen WARNING: lavapipe is not a conformant vulkan implementation, testing use only.) as my renderer reports ok and glxgears runs fine as well as other apps like audio and 4k youtube playback. I am trying to figure out now if I can get vurtualgl to run and force hardware rendering on glxgears though vglrun glxgears etc.

hope it helps, I think most of the issues with X and wslg are misunderstandings on what to build and in what sequence.

Does virtualgl run under WSL ?

jimthedj65 commented 1 year ago

I have this very predictable now, systemd in wsl.conf definitely breaks wslg and when turning off, allows the renderer to come back again and allows the the X0 to be created. Also thankfully I have google-chrome more stable, most of it was solved by installing from the store and using windows terminal instead of powershell, powershell breaks very easily with paths and so on.

I hope it helps someone to know that it is definitely bleeding edge all of this, so much conflicting information about the sequence of events of what to install and how, very easy to break stuff. I still have issues runner docker ML and cuda samples but in general its all working for apps and X11 apps. I have upgraded to latest Nvidia drivers 526.86

Inxi -G reports

Graphics: Device-1: Microsoft driver: dxgkrnl v: 2.0.1 Display: wayland-0 server: Microsoft Corporation X.org 1.20.13 driver: fbdev,vesa unloaded: modesetting resolution: 3840x1080~60Hz, 1024x640~60Hz OpenGL: renderer: D3D12 (NVIDIA GeForce RTX 3080 Ti) v: 3.3 Mesa 21.2.6

Chrome://gpu reports GPU0 VENDOR= 0x1414 [Google Inc. (Microsoft Corporation)], DEVICE=0x008e [ANGLE (Microsoft Corporation, D3D12 (NVIDIA GeForce RTX 3080 Ti), OpenGL 3.3 (Core Profile) Mesa 21.2.6)], DRIVER_VENDOR=Mesa, DRIVER_VERSION=21.2.6 *ACTIVE*

jimthedj65 commented 1 year ago

On the subject of Cuda when running latest ubuntu 22.04 and followng the standard nvidia instructions [https://docs.nvidia.com/cuda/wsl-user-guide/index.html]

Dockerd runs as in the background (daemon) docker run --gpus all nvcr.io/nvidia/k8s/cuda-sample:nbody nbody -gpu -benchmark

NOTE: The CUDA Samples are not meant for performance measurements. Results may vary when GPU Boost is enabled.

Error: only 0 Devices available, 1 requested. Exiting. when I RUN nvidia-smi dockker build docker run -it --gpus=all --rm nvidia/cuda:11.4.2-base-ubuntu20.04 nvidia-smidocker run -it --gpus=all --rm nvidia/cuda:11.4.2-base-ubuntu20.04 nvidia-smi

Dameon reports ERRO[2022-11-13T22:39:04.629102170Z] copy shim log error="read /proc/self/fd/14: file already closed" ERRO[2022-11-13T22:39:04.631153170Z] stream copy error: reading from a closed fifo ERRO[2022-11-13T22:39:04.886924164Z] 751dd3ef0a1bbbdc1c1884e890cf8be249e3064c3053370380b4aea95d7ffeeb cleanup: failed to delete container from containerd: no such container

when sunning hashcat docker docker run -it --gpus=all --rm dizcza/docker-hashcat //bin/bash The docker loads but reports an error

hashcat -b hashcat (v6.2.6) starting in benchmark mode

Benchmarking uses hand-optimized kernel code by default. You can use it in your cracking session by setting the -O option. Note: Using optimized kernel code limits the maximum supported password length. To disable the optimized kernel code in benchmark mode, use the -w option.

cuInit(): no CUDA-capable device is detected

clGetPlatformIDs(): CL_PLATFORM_NOT_FOUND_KHR

ATTENTION! No OpenCL, HIP or CUDA compatible platform found.

You are probably missing the OpenCL, CUDA or HIP runtime installation.

Started: Sun Nov 13 22:45:02 2022 Stopped: Sun Nov 13 22:45:02 2022

nvidia-smi runs fine

root@eb5bc0c0d375:~# nvidia-smi Sun Nov 13 22:45:14 2022 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 525.46 Driver Version: 526.86 CUDA Version: 10.2 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | | | | MIG M. | |===============================+======================+======================| | 0 NVIDIA GeForce ... On | 00000000:01:00.0 On | N/A | | 47% 47C P8 20W / 350W | 637MiB / 12288MiB | 0% Default | | | | N/A | +-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+ | Processes: | | GPU GI CI PID Type Process name GPU Memory | | ID ID Usage | |=============================================================================| | 0 N/A N/A 21 G /Xwayland N/A | | 0 N/A N/A 32 G /Xwayland N/A | +-----------------------------------------------------------------------------+ root@eb5bc0c0d375:~#

deviceQuery from the samples runs fine

./deviceQuery Starting...

CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "NVIDIA GeForce RTX 3080 Ti" CUDA Driver Version / Runtime Version 12.0 / 11.8 CUDA Capability Major/Minor version number: 8.6 Total amount of global memory: 12288 MBytes (12884377600 bytes) (080) Multiprocessors, (128) CUDA Cores/MP: 10240 CUDA Cores GPU Max Clock rate: 1695 MHz (1.70 GHz) Memory Clock rate: 9501 Mhz Memory Bus Width: 384-bit L2 Cache Size: 6291456 bytes Maximum Texture Dimension Size (x,y,z) 1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384) Maximum Layered 1D Texture Size, (num) layers 1D=(32768), 2048 layers Maximum Layered 2D Texture Size, (num) layers 2D=(32768, 32768), 2048 layers Total amount of constant memory: 65536 bytes Total amount of shared memory per block: 49152 bytes Total shared memory per multiprocessor: 102400 bytes Total number of registers available per block: 65536 Warp size: 32 Maximum number of threads per multiprocessor: 1536 Maximum number of threads per block: 1024 Max dimension size of a thread block (x,y,z): (1024, 1024, 64) Max dimension size of a grid size (x,y,z): (2147483647, 65535, 65535) Maximum memory pitch: 2147483647 bytes Texture alignment: 512 bytes Concurrent copy and kernel execution: Yes with 1 copy engine(s) Run time limit on kernels: Yes Integrated GPU sharing Host Memory: No Support host page-locked memory mapping: Yes Alignment requirement for Surfaces: Yes Device has ECC support: Disabled Device supports Unified Addressing (UVA): Yes Device supports Managed Memory: Yes Device supports Compute Preemption: Yes Supports Cooperative Kernel Launch: Yes Supports MultiDevice Co-op Kernel Launch: No Device PCI Domain ID / Bus ID / location ID: 0 / 1 / 0 Compute Mode: < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 12.0, CUDA Runtime Version = 11.8, NumDevs = 1 Result = PASS

hideyukn88 commented 1 year ago

Currently we are investigating X socket doesn't present when systemd is enabled, it is not happening every environment, such as specific distro, but we do observe in various situation, so as workaround, please try workaround mentioneed at https://github.com/microsoft/WSL/issues/9158, or disable systemd if possible. If you are experiencing this issue without systemd enabled (and make sure on the latest WSL 1.0.0.0), please let us know, thanks!

ajkelsey commented 1 year ago

I updated to WSL 1.0. Enabled systemd. Ran the following commands:

sudo systemd-tmpfiles --boot --create sudo ln -sf /mnt/wslg/.X11-unix /tmp/.X11-unix

This has not resolved my issue. I cannot open Firefox or Wireshark. However, I can open mousepad and mate-calc.

imaginabit commented 1 year ago

I updated to WSL 1.0. Enabled systemd. Ran the following commands:

sudo systemd-tmpfiles --boot --create sudo ln -sf /mnt/wslg/.X11-unix /tmp/.X11-unix

This has not resolved my issue. I cannot open Firefox or Wireshark. However, I can open mousepad and mate-calc.

Thanks, I can open xeyes and other apps, but can't open Firefox installed via snap, but can open Firefox downloaded from AppImage

looks like I can't open any app installed with snap

hideyukn88 commented 1 year ago

If you are seeing X11 socket connection issue on Ubuntu, with systemd enabled, please check if gdm service is installed and running by systemctl -t service | grep gdm.service, please let us know, thanks!

crramirez commented 1 year ago

@hideyukn88 this means that it should or should not be installed and running?

hideyukn88 commented 1 year ago

@crramirez, gdm.service is automatically installed when certain GNOME software is installed, and currently we are thinking this is conflicting with WSLg. Thus, if the service is running, please disable it by sudo systemctl disable gdm.service, then restart WSL. This should restore X connection by WSLg, thanks!

rye2020 commented 1 year ago

Fixed my X0 problem!  Thank you. Sent from my iPhoneOn Nov 18, 2022, at 11:56 AM, Hideyuki Nagase @.***> wrote: @crramirez, gdm.service is automatically installed when certain GNOME software is installed, and currently we are thinking this is conflicting with WSLg. Thus, if the service is running, please disable it by sudo systemctl disable gdm.service, then restart WSL. This should restore X connection by WSLg, thanks!

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

jnusbaum commented 1 year ago

@crramirez, gdm.service is automatically installed when certain GNOME software is installed, and currently we are thinking this is conflicting with WSLg. Thus, if the service is running, please disable it by sudo systemctl disable gdm.service, then restart WSL. This should restore X connection by WSLg, thanks!

Just a note that this worked for me.

kasvith commented 1 year ago

Im having similar problem

when i do ls /mnt i dont see wslg directory

ajkelsey commented 1 year ago

Problem has been resolved with the latest WSL upgrade. I have enabled systemd and all appears to be functioning.

WSL version: 1.0.3.0 Kernel version: 5.15.79.1 WSLg version: 1.0.47 MSRDC version: 1.2.3575 Direct3D version: 1.606.4 DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp Windows version: 10.0.22621.963

kasvith commented 1 year ago

Problem has been resolved with the latest WSL upgrade. I have enabled systemd and all appears to be functioning.

WSL version: 1.0.3.0 Kernel version: 5.15.79.1 WSLg version: 1.0.47 MSRDC version: 1.2.3575 Direct3D version: 1.606.4 DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp Windows version: 10.0.22621.963

I also solved it the same way