【问题标题】:AWS: Exception:It appears that you are attempting to reference SparkContext from a broadcast variable. SparkContext can only be used on the driverAWS:异常:您似乎正在尝试从广播变量中引用 SparkContext。 SparkContext 只能在驱动上使用
【发布时间】:2019-07-21 17:07:48
【问题描述】:

尝试在 AWS Amazon 集群上运行我的程序时。

[hadoop@ip-172-31-5-232 ~]$ spark-submit 6.py .

我收到以下错误:

Exception: It appears that you are attempting to reference SparkContext from a broadcast variable, action, or transformation. SparkContext can only be used on the driver, not in code that it run on workers. For more information, see SPARK-5063.

这是我出现错误的代码示例:

result= l.map(lambda x : (x[0], list(x[1]))).collect()
if (NbrVertex > (2*(len(filteredResults.collect())+ ExtSimilarity))):

Successor=filteredResults3.map(lambda j:matchedSuccessor(j,result))

  print(Successor.collect())

你可以看下图]1

【问题讨论】:

  • 如果你能粘贴你的代码就很容易了
  • 这个答案有帮助吗?

标签: amazon-web-services apache-spark amazon-s3 amazon-ec2 aws-lambda


【解决方案1】:

collect 导致数据进入驱动程序。

Successor ... 因此通过 .map 从 Worker 引用 Driver。不允许。

消息证实了 Spark 范式。

【讨论】:

  • 上下文对我来说不清楚,所以很难建议。怀疑您需要广播或删除收集或组合。这是一个很大的话题。
  • 我尝试了这两种解决方案,但仍然出现相同的错误...请您通过 Hangout 或 teamviewer 帮助我,我可以向您解释为什么我使用该功能,而您仍然是我如何更改它
  • 这是一个不同的问题。很清楚问题是什么,但如何解决是一个不同的问题。这就是它在这里的工作方式。请接受这个答案并发布一个我将查看的新问题。
猜你喜欢
  • 1970-01-01
  • 2022-01-27
  • 1970-01-01
  • 1970-01-01
  • 2015-02-01
  • 2022-10-25
  • 1970-01-01
相关资源
最近更新 更多