pytorch在WSL2下运行的“被杀死”即使我剩下很多记忆,也没有记忆?

发布于 2025-02-09 07:00:22 字数 366 浏览 1 评论 0原文

我在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

阳光的暖冬 2025-02-16 07:00:22

根据此博客文章A>,WSL2自动配置为使用机器的物理RAM的50%。您需要将放置在Windows Home Directory中的.wslConfig文件添加MOMORY = 48GB(或您的首选设置) {用户名} \ )。

[wsl2]
memory=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}\).

[wsl2]
memory=48GB

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文