有没有办法限制Bazel使用的CPU内核数量? [英] Is there a way to limit the number of CPU cores Bazel uses?

查看:613
本文介绍了有没有办法限制Bazel使用的CPU内核数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在构建Bazel可以使用多少个CPU内核时,是否有办法告诉Bazel?

Is there a way to tell Bazel when building how many CPU cores it can use?

我在VMware Workstation上构建TensorFlow,并且作为虚拟机,我可以调整虚拟机的处理器和核心数量.

I build TensorFlow on a VMware Workstation and being a virtual machine I can adjust the number of processors and cores for the virtual machine.

在构建TensorFlow的过程中,我发现仅使用一个核心即可. 当我为Workstation提供四个内核并构建TensorFlow时,它最终使系统停止运行,直到必须重新启动.

In the process of building TensorFlow I found that using only one core works. When I give the Workstation four cores and build TensorFlow it eventually halts the system to the point I have to reboot.

如果我等待几个小时(将其放置一整夜),有时会返回以下错误:

If I wait a few hours (leave it alone overnight) it sometimes returns with the following error:

gcc:内部编译器错误:已杀死(程序cc1plus)

gcc: internal compiler error: Killed (program cc1plus)

虽然我可以使用虚拟机配置选项更改内核数,但我希望这样做而不必关闭并重新启动虚拟机.

While I can change the number of cores using the virtual machines configuration options I would prefer to do it without having to shut down and restart the virtual machine.

推荐答案

来自 Bazel用户手册

--local_resources availableRAM,可用的CPU ,可用的IO

--local_resources availableRAM,availableCPU,availableIO

此选项,需要三个逗号分隔的浮点数 参数,指定Bazel可以占用的本地资源量 在计划构建和测试活动时要考虑到这一点.选项 预计可用RAM(MB), CPU内核数(含1.0) 代表单个全核)和工作站I/O功能(具有 1.0代表普通工作站).默认情况下,Bazel将直接从系统估计RAM的数量和CPU内核的数量 配置,并假定1.0 I/O资源.

This option, which takes three comma-separated floating point arguments, specifies the amount of local resources that Bazel can take into consideration when scheduling build and test activities. Option expects amount of available RAM (in MB), number of CPU cores (with 1.0 representing single full core) and workstation I/O capability (with 1.0 representing average workstation). By default Bazel will estimate amount of RAM and number of CPU cores directly from system configuration and will assume 1.0 I/O resource.

如果使用此选项,Bazel将忽略两者 --ram_utilization_factor.

If this option is used, Bazel will ignore both --ram_utilization_factor.

这篇关于有没有办法限制Bazel使用的CPU内核数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆