调用ray的c++ api,在在不同节点间传输large data(例如4GB大小),适合用什么数据类型?目前采用vector,太大会报错。另外,速度非常的慢,比起python传输numpy数据,慢了几百倍。

#include <stdlib.h>
#include
#include
#include <ray/api.h>
#include

using namespace std;

#define DATAGB 1
const size_t dataSize = DATAGB10241024300; //102410241024

char transfer_data(std::vector obj)
{
char stat = obj[0] + obj[1];
return stat;
}

// 声明为远程函数
RAY_REMOTE(transfer_data);

int main(int argc, char **argv)
{
ray::Init();
std::vector arr(dataSize, 10);

for(int i=0;i<100;i++)
{
    chrono::steady_clock::time_point beforeTime = std::chrono::steady_clock::now();
    auto task_object_arr = ray::Put(arr);
    auto task_object = ray::Task(transfer_data).Remote(task_object_arr);
    auto task_result = *(ray::Get(task_object));

    chrono::steady_clock::time_point afterTime = std::chrono::steady_clock::now();
    auto duration_millsecond = std::chrono::duration<double, std::milli>(afterTime - beforeTime).count();
    float duration_second = duration_millsecond /1000.0;
    float dataSizeGB = dataSize/1024.0/1024.0/1024.0;
    printf("Transfer: %f GB , cost:%.2f seconds, bandwidth = %.2fGbps \n",dataSizeGB, duration_second, dataSizeGB/duration_second*8);
}
ray::Shutdown();

}
代码如上

查看了日记,可能是这个错误
[2024-04-17 22:15:55,590 W 1569171 1569196] metric_exporter.cc:105: [1] Export metrics to agent failed: GrpcUnavailable: RPC Error message: failed to connect to all addresses; last error: UNKNOWN: ipv4:127.0.0.1:65535: Failed to connect to remote host: Connection refused; RPC Error details: . This won’t affect Ray, but you can lose metrics from the cluster.