【发布时间】:2022-01-15 17:37:08
【问题描述】:
以下谷歌云功能在本地运行良好,但在云上部署时失败。
from flask import escape
import functions_framework
import numpy as np
@functions_framework.http
def test_func(request):
np_array = np.zeros(172128250, dtype=np.complex64)
print('np_array shape: ', np_array.shape)
abs_array = np.abs(np_array)
print('abs_array shape: ', abs_array.shape)
return 'Hello World'
尝试过的 Python 版本:3.7、3.8 和 3.9。
超时:540 秒
内存:8GB
np_array 已成功创建,但无法计算 abs。函数打印第一个日志np_array shape: (172128250,),但无法打印第二个日志。函数突然退出打印Function execution took 2408 ms, finished with status: 'connection error'。它适用于本地的所有大小,但在云端,它特别适用于以下 10 种大小的 NumPy 数组[172128241, 172128242, ..., 172128250]。
【问题讨论】:
-
你没有其他日志吗?好奇怪……
-
@guillaumeblaquiere 是的,我看到一个警告。
OpenBLAS WARNING - could not determine the L2 cache size on this system, assuming 256k。实际上,这个错误是在某些librosa函数内部调用np.abs时发生的。经过多次迭代的调试,我得到了这两行代码。最初,np_array 是二维的1025 * 167930 -
@guillaumeblaquiere ,我感觉这是由于云上的一些内存分配问题。我发现了另外六个大小为 10 的范围,它们失败了
{172127217, ..., 172127226}, {172127217..172127226}, {172126193..172126202}, {172125169..172125178}, {172124145..172124154}, {172123121..172123130}。请注意,这些范围之间的差异正好是1024。
标签: python python-3.x numpy google-cloud-platform google-cloud-functions