New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WSL 2 uses half the number of cores on AMD Threadripper 3990X #5423
Comments
Not sure if it is relevant but I am experiencing the same issue in hyper-V too. |
It's the kernel config. Look at https://github.com/microsoft/WSL2-Linux-Kernel/tree/master/Microsoft. In the config for x86_64 you will see it's set to 64. This is standard from the Linux kernel. What you can do is update the config to match the number of cores you have. Ideally WSL would do a check on the number of CPU cores and update the config appropriately in |
@WSLUser , thanks for the answer. Just to confirm, you meant updating
Are you suggesting that despite the range, WSL 2 uses the default value as a max value? My apologies if I misunderstood your suggestion. |
You have to create .wslconfig. https://docs.microsoft.com/en-us/windows/wsl/release-notes#build-18945 |
@WSLUser thank you again for the suggestion and sorry for the misunderstanding on my part. I tried your method to change the number of processors. It works when I decrease the number of processors but unfortunately, it doesn't work passed the 64 processor (which is equivalent to 32 physical processors). it seems to still limit me to half of number of physical cores (64/2 = 32). |
@WSLUser Does this work also for multiple CPUs? i.e. Dual Xeon setup? |
Not sure. @craigloewen-msft would probably know better. In your case it appears the kernel config itself needs updating. You should be able to override the original value in .wslconfig as well. You should see the option in the release notes. And yes (sorry I didn't answer before), it's using the default value. So you'll overwrite it. I don't recommend going above 256. |
@WSLUser Thanks for all the help, I guess I will wait for the kernel to be updated. |
@AAlMutairi not yet,not sure if it applies to dual cpu setups as well. If it does, I'll try. |
Any updates or fixes to test? |
It affect compiling also when running make -j. Only half of CPUs used whereas WSL1 does not have this issue. Ryzen 2600, Ubuntu 20.04 WSL2 |
This basically blocks any usage of WSL 2, even if I check out my repo there, I lose 50% of my processing power.. That's simply a no go. |
@mozram, it is surprising that it was working for you in WSL 1. Unfortunately for me, Both don't work for me. |
@sanastasiou , hopefully any fix can work for both WSL 2 and hyper-V since the issue persist in both. |
Interestingly, even when I used mpich on windows, it only sees 32 physical cores. I guess this issue isn't just limited to WSL or hyper-V |
Any updates? |
Changing WSL config has 0 effect whatsoever. 2nd CPU is not recognized. |
I tried contacting AMD customer support about the issue and if they have any fixes but to no avail. |
Ben said "I am already looking into this, AMD brought this to my attention as well." |
Not quite true, I have a dual xeon setup and it only detects one of them. So it doesn't affect only 3990X |
@sanastasiou , my apologies, I meant within the AMD thread ripper line, only the 3990x is affected. by the way, did you test if the same issue persists when you use hyper-V? because it is the case for me. |
I have the same issue with Intel Xeon. I have two 6242R CPUs (2 sockets), and only 1 socket is available from WSL 2. |
@ykim362 Which Windows are you using? Do you have the same issue with hyper-V? |
@AAlMutairi how do I enable/how can I check this with Hyper-V? |
@sanastasiou it is similar to WSL in which you enable it through the "Turn Windows features on or off" as shown here: Then use the "Hyper-V quick create" as shown here (based on old windows but it is still the same): I guess you can install an Ubuntu VM for now. if you right click on the VM you can access it setting and change the number of cores and sockets you want. Then you can run and test. |
@AAlMutairi I was able to configure the number of virtual cores (2 x physical cores) with Hyper-V (on windows 10 enterprise). But, I am not sure it's really using all CPUs, or just doing virtually showing 2x more cpus. It was 40 logical cores (20 physical cores) by default, and even after I increased the number to 80 logical cores, it only shows as 1 socket. lscpu Architecture: x86_64 |
@alice-comfy, would it be okay for you to share which version of Windows you are using? and regarding hyper-V, have you tested that it actually uses all 96 physical cores you allocated? Windows can be a bit weird when it comes to virtualisation. |
Windows 11 22h2 Build 22621.2715. Ubuntu detects 96 threads when I send them through. I changed it to 192 and that works too. Hyper-V: 192 CPUs |
alice-comfy, I got involved very early in this issue. Since you are running an AMD processor, I suggest you install and run Ryzen Master. It will tell you exactly what cores/threads are doing what. Enjoy, John. |
Can't use Ryzen Master on EPYC (that ES is a 9654 96 core chip, I use it as a workstation CPU). I also tried canary builds to see if later versions of windows had it fixed, and it hits the same snag. Windows Sandbox is also limited to 64 threads by default, but as shown above Hyper-V works great with any number of cores. From testing with VMs, it will use either 64 threads if you have >64 threads on a single socket, or the number of threads a single CPU has if you have a dual socket system. paging @craigloewen-msft in case he has any insights here. |
Hoping with this new release we might see more work on this issue. https://www.phoronix.com/review/threadripper-7995wx-windows-linux |
Device name Server lscpu
htop I have 2 sockets (2 cpus) each with 14 cores and 28 threads, and now I can recognize all the cores in wsl2 pretty well, but numa can't recognize 2. This also causes all numa2 kernels to be identified as numa1 hyperthreads. This has a significant impact on performance. I think this is a big problem, although I can manually specify make-j56 to use all the threads, but for a program like pytorch it can only fully utilize the first processor. The second should be treated as hyperthreading, is there a way to fix this? |
I think this is a wsl's bug. I think in It's better to invoke Now all cores works: |
Absolutely amazing! How'd you get the code for the exe, I thought that was closed source? |
I don't have the source code. That exe just invokes windows api to create VM. These apis exist in |
Hi, have you try to stress the cpu to check if it can truely utilize all the cores? And maybe consider @ someone from the wsl team? |
Yes, I believe it can truely utilize all the cores, but you need change the hyperV scheduler type to "Core". I added an instruction about how to do it: xieyubo/WSL2@41511c9 |
Amazing work @xieyubo, I do not have time to test it now, but I will share an update once I test it. Looking forward for others testing this workaround. @benhillis we would appreciate your feedback on this workaround. |
|
@Vincentzyx thank you for testing it. So it clearly works. I am excited to test it on my setup. Might test the performance of my simulations with this vs when I disable SMT. |
@therealkenc Hi, someone seems to solve this issue, see messages above |
hi @xieyubo , i have been trying to follow your instructions. however, my WSL does not have any wslservice.exe nor do i have a directory called WSL anywhere. I installed my Ubuntu from the windows store, so installation data is in Program Files\WindowsApps. However, nowhere can i find any WSL directory or wslservice.exe. |
@geth03 maybe you can try to delete the WSL which you installed from the windows store, and re-install it from "Control Panel -> Programs -> Programs and Features -> Turn Windows features on or off -> Windows Subsystem for Linux" |
Hi. I have been running the cmake and no errors have occurred. However, I cant find the computecore.dll in the build directory. |
1 similar comment
Hi. I have been running the cmake and no errors have occurred. However, I cant find the computecore.dll in the build directory. |
Do you do the step 2? "Open build/Project.sln and generate a x64 release build." :) |
You can launch |
Can you please send compiled dll? Cant undestand how to compile by myself |
Hey guys got a dual Intel Xeon Gold 6430 with the same problem only utilising 64 out of my 128 cores; any chance that this pushed to upstream? We cant really compile from scratch as its a corporate environment however it still a slightly bigger issue for us as it wont be approved in a package push |
I'm hoping for some positive news given David Cutler mentioned in his interview with Dave's Garage that he's rocking a 96 core PC as his personal system. Given the need for either a Hyper-V change, or to override the scheduler (from root to core), I don't think this will happen before the next major version (25H2? or 12) |
Its just a overriding the scheduler thats the issue, you also need that custom dll to capture all cores, hoping they fix it soon. |
Environment
Steps to reproduce
I am using AMD threadripper 3990x in my PC. when I use the command lscpu I get the following
Also when I use the command nproc, I get 64.
However, using both openmpi and mpich to run parallel job, mpi uses only 32 cores (half real cores). For this test I used the following code (copied from: https://mpitutorial.com/tutorials/mpi-hello-world/)
Expected behavior
Actual behavior
The text was updated successfully, but these errors were encountered: