问题描述
我正在尝试训练一个非常消耗内存的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*,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
看来我不能强迫节点拥有更多的内存!即使当前在我的计算机上安装了32 GB,其中只有17GB被占用,所以如果有的话,它应该至少增加到15GB。但通常会在分配3-5GB后消失。
这是Node.js中的错误吗?也许是早期版本的回归?我是否有任何选择,或者可能不得不重新编译自己的Node二进制文件?如果我这样做,那行得通吗?
编辑:我运行64位节点。 node -p "os.arch()"
说x64
。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)