gpt4 book ai didi

apache-spark - Spark : out of memory when broadcasting objects

转载 作者:行者123 更新时间:2023-12-05 00:18:05 28 4
gpt4 key购买 nike

我尝试广播一个不太大的 map (作为文本文件保存到 HDFS 时约为 70 MB),但出现内存不足错误。我尝试将驱动程序内存增加到 11G,将执行程序内存增加到 11G,但仍然出现相同的错误。 memory.fraction 设置为 0.3,缓存的数据也不多(小于 1G)。

本地图只有 2 MB 左右时,没有问题。我想知道广播对象时是否有大小限制。如何使用更大的 map 解决这个问题?谢谢!

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.IdentityHashMap.resize(IdentityHashMap.java:469)
at java.util.IdentityHashMap.put(IdentityHashMap.java:445)
at org.apache.spark.util.SizeEstimator$SearchState.enqueue(SizeEstimator.scala:159)
at org.apache.spark.util.SizeEstimator$.visitArray(SizeEstimator.scala:229)
at org.apache.spark.util.SizeEstimator$.visitSingleObject(SizeEstimator.scala:194)
at org.apache.spark.util.SizeEstimator$.org$apache$spark$util$SizeEstimator$$estimate(SizeEstimator.scala:186)
at org.apache.spark.util.SizeEstimator$.estimate(SizeEstimator.scala:54)
at org.apache.spark.util.collection.SizeTracker$class.takeSample(SizeTracker.scala:78)
at org.apache.spark.util.collection.SizeTracker$class.afterUpdate(SizeTracker.scala:70)
at org.apache.spark.util.collection.SizeTrackingVector.$plus$eq(SizeTrackingVector.scala:31)
at org.apache.spark.storage.MemoryStore.unrollSafely(MemoryStore.scala:278)
at org.apache.spark.storage.MemoryStore.putIterator(MemoryStore.scala:165)
at org.apache.spark.storage.MemoryStore.putIterator(MemoryStore.scala:143)
at org.apache.spark.storage.BlockManager.doPut(BlockManager.scala:801)
at org.apache.spark.storage.BlockManager.putIterator(BlockManager.scala:648)
at org.apache.spark.storage.BlockManager.putSingle(BlockManager.scala:1006)
at org.apache.spark.broadcast.TorrentBroadcast.writeBlocks(TorrentBroadcast.scala:99)
at org.apache.spark.broadcast.TorrentBroadcast.<init>(TorrentBroadcast.scala:85)
at org.apache.spark.broadcast.TorrentBroadcastFactory.newBroadcast(TorrentBroadcastFactory.scala:34)
at org.apache.spark.broadcast.BroadcastManager.newBroadcast(BroadcastManager.scala:63)
at org.apache.spark.SparkContext.broadcast(SparkContext.scala:1327)

编辑:
根据评论添加更多信息:
  • 我使用 spark-submit 在客户端模式下提交编译好的 jar 文件。 Spark 1.5.0
  • spark.yarn.executor.memoryOverhead 600
  • 设置(“spark.kryoserializer.buffer.max”,“256m”)
  • set("spark.speculation", "true")
  • set("spark.storage.memoryFraction", "0.3")
  • set("spark.driver.memory", "15G")
  • 设置(“spark.executor.memory”,“11G”)
  • 我试过 set("spar.sql.tungsten.enabled", "false") 并没有帮助。
  • 主机有60G内存。大约 30G 用于 Spark/Yarn。我不确定我的工作需要多少堆大小,但同时没有太多其他进程在进行。特别是 map 只有70MB左右。

  • 一些与广播相关的代码:
    val mappingAllLocal: Map[String, Int] = mappingAll.rdd.map(r => (r.getAs[String](0), r.getAs[Int](1))).collectAsMap().toMap
    // I can use the above mappingAll to HDFS, and it's around 70MB
    val mappingAllBrd = sc.broadcast(mappingAllLocal) // <-- this is where the out of memory happens

    最佳答案

    使用 set("spark.driver.memory", "15G")对客户端模式没有影响。你必须使用命令行参数--conf="spark.driver.memory=15G"在提交应用程序时增加驱动程序的堆大小。

    关于apache-spark - Spark : out of memory when broadcasting objects,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38623885/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com