pytorch在WSL2下运行的“被杀死”即使我剩下很多记忆,也没有记忆?
我在Windows 11上使用WSL2(用于Linux的Windows子系统)。我最近将RAM从32 GB升级到64 GB。
虽然我可以使计算机使用超过32 GB的RAM,但WSL2似乎拒绝使用超过32 GB。例如,如果我
>>> import torch
>>> a = torch.randn(100000, 100000) # 40 GB tensor
这样做,我会看到记忆使用量会上升,直到它撞到30次GB,这时我会看到“杀死”,而Python过程被杀死。检查dmesg
,它说它杀死了该过程,因为“不在内存”。
知道问题可能是什么,或者解决方案是什么?
I'm on Windows 11, using WSL2 (Windows Subsystem for Linux). I recently upgraded my RAM from 32 GB to 64 GB.
While I can make my computer use more than 32 GB of RAM, WSL2 seems to be refusing to use more than 32 GB. For example, if I do
>>> import torch
>>> a = torch.randn(100000, 100000) # 40 GB tensor
Then I see the memory usage go up until it hit's 30-ish GB, at which point, I see "Killed", and the python process gets killed. Checking dmesg
, it says that it killed the process because "Out of memory".
Any idea what the problem might be, or what the solution is?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据此博客文章A>,WSL2自动配置为使用机器的物理RAM的50%。您需要将放置在Windows Home Directory中的
.wslConfig
文件添加MOMORY = 48GB
(或您的首选设置) {用户名} \ )。添加此文件后,关闭您的分发并至少等待 8秒重新启动之前。
假设Windows 11将需要大量开销才能操作,因此将其设置为使用完整的64 GB会导致Windows OS用完存储器。
According to this blog post, WSL2 is automatically configured to use 50% of the physical RAM of the machine. You'll need to add a
memory=48GB
(or your preferred setting) to a.wslconfig
file that is placed in your Windows home directory (\Users\{username}\
).After adding this file, shut down your distribution and wait at least 8 seconds before restarting.
Assume that Windows 11 will need quite a bit of overhead to operate, so setting it to use the full 64 GB would cause the Windows OS to run out of memory.