如何强制Node.js(v14)使用更多RAM?

如何强制Node.js(v14)使用更多RAM?,node.js,tensorflow,tfjs-node,tensorflow.js,Node.js,Tensorflow,Tfjs Node,Tensorflow.js,我正在尝试训练一个非常需要内存的Tensorflow.js模型,但是我遇到了一些非常奇怪的Node.js行为 $ node --max-old-space-size=16384 --initial-old-space-size=16384 --max-heap-size=16384 --initial-heap-size=16384 index.js 2020-08-19 11:32:56.190067: I tensorflow/core/platform/cpu_feature_guard.

我正在尝试训练一个非常需要内存的Tensorflow.js模型,但是我遇到了一些非常奇怪的Node.js行为

$ node --max-old-space-size=16384 --initial-old-space-size=16384 --max-heap-size=16384 --initial-heap-size=16384 index.js
2020-08-19 11:32:56.190067: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2020-08-19 11:32:56.213573: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 3400000000 Hz
2020-08-19 11:32:56.216786: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x55fce50 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-08-19 11:32:56.217643: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version


<--- Last few GCs --->

[19219:0x44d06a0]   162448 ms: Scavenge 4047.5 (4054.3) -> 4047.5 (4054.3) MB, 26.0 / 0.0 ms  (average mu = 0.989, current mu = 0.989) allocation failure
[19219:0x44d06a0]   163150 ms: Scavenge 4430.0 (4436.8) -> 4430.0 (4436.8) MB, 36.0 / 0.0 ms  (average mu = 0.989, current mu = 0.989) allocation failure
[19219:0x44d06a0]   164237 ms: Scavenge 5003.8 (5010.6) -> 5003.8 (5010.6) MB, 51.5 / 0.0 ms  (average mu = 0.989, current mu = 0.989) allocation failure


<--- JS stacktrace --->

FATAL ERROR: invalid array length Allocation failed - JavaScript heap out of memory
 1: 0x9fd5f0 node::Abort() [node]
 2: 0x94a45d node::FatalError(char const*, char const*) [node]
 3: 0xb7099e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
 4: 0xb70d17 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
 5: 0xd1a905  [node]
 6: 0xcf3445  [node]
 7: 0xe7b96e  [node]
 8: 0xe7baba  [node]
 9: 0x10185b3 v8::internal::Runtime_GrowArrayElements(int, unsigned long*, v8::internal::Isolate*) [node]
10: 0x13cc8f9  [node]
[1]    19219 abort (core dumped)  node --max-old-space-size=16384 --initial-old-space-size=16384   index.js
$node--最大旧空间大小=16384--初始旧空间大小=16384--最大堆大小=16384--初始堆大小=16384 index.js
2020-08-19 11:32:56.190067:I tensorflow/core/platform/cpu\u feature\u guard.cc:142]您的cpu支持该tensorflow二进制文件未编译为使用的指令:AVX2 FMA
2020-08-19 11:32:56.213573:I tensorflow/core/platform/profile_utils/cpu_utils.cc:94]cpu频率:34000000000 Hz
XLA XLA服务0x55 FCE50初始化为平台主机(这并不保证XLA将被使用)。设备:
2020-08-19 11:32:56.217643:I tensorflow/compiler/xla/service/service.cc:176]StreamExecutor设备(0):主机,默认版本
[19219:0x44d06a0]162448毫秒:清除4047.5(4054.3)->4047.5(4054.3)MB,26.0/0.0毫秒(平均mu=0.989,当前mu=0.989)分配失败
[19219:0x44d06a0]163150毫秒:清除4430.0(4436.8)->4430.0(4436.8)MB,36.0/0.0毫秒(平均mu=0.989,当前mu=0.989)分配失败
[19219:0x44d06a0]164237毫秒:清除5003.8(5010.6)->5003.8(5010.6)MB,51.5/0.0毫秒(平均mu=0.989,当前mu=0.989)分配失败
致命错误:无效的数组长度分配失败-JavaScript堆内存不足
1:0x9fd5f0节点::中止()[节点]
2:0x94a45d节点::FatalError(字符常量*,字符常量*)[node]
3:0xb7099e v8::Utils::ReportOOMFailure(v8::internal::Isolate*,char const*,bool)[节点]
4:0xb70d17 v8::internal::v8::FatalProcessOutOfMemory(v8::internal::Isolate*,char const*,bool)[节点]
5:0xd1a905[节点]
6:0xcf3445[节点]
7:0xe7b96e[节点]
8:0xe7baba[节点]
9:0x10185b3 v8::internal::Runtime_GrowArrayElements(int,unsigned long*,v8::internal::Isolate*)[节点]
10:0x13cc8f9[节点]
[1] 19219中止(内核转储)节点--最大旧空间大小=16384--初始旧空间大小=16384 index.js
似乎我无法强制节点拥有更多内存!即使在我的机器上,目前安装了32GB,其中只有17GB被占用,所以如果有任何问题的话,它应该至少占用15GB。但它通常在分配了3-5GB之后就消失了

这是Node.js中的错误吗?也许是早期版本的回归?我是否有任何选择,或者可能需要重新编译自己的节点二进制文件?如果我这么做了,那行吗


编辑:我运行64位节点
node-p“os.arch()”
表示
x64

啊,很抱歉我忘了指定,“当然”我运行64位
node-p“os.arch()”
表示
x64
您是否介意运行以定义这是否是node.js问题?@ManuelSpigolon当然。我已经运行了它和一个稍微大一点的变体。啊,很抱歉我忘了指定,“当然”我运行64位
node-p“os.arch()”
表示
x64
您是否介意运行以定义这是否是node.js问题?@ManuelSpigolon当然。我已经运行了它和一个稍大的变体,并且。