如何运行大型mahout模糊kmeans集群而不耗尽内存?

wfsdck30  于 2021-06-03  发布在  Hadoop
关注(0)|答案(1)|浏览(423)

我在amazon的emr(ami2.3.1)上运行mahout 0.7模糊k-means聚类,内存不足。
我的总体问题是:如何让它最容易工作?
下面是一个调用:

./bin/mahout fkmeans \
  --input s3://.../foo/vectors.seq \
  --output s3://.../foo/fuzzyk2 \
  --numClusters 128 \
  --clusters s3://.../foo/initial_clusters/ \
  --maxIter 20 \
  --m 2 \
  --method mapreduce \
  --distanceMeasure org.apache.mahout.common.distance.TanimotoDistanceMeasure

更详细的问题:
我怎么知道我用了多少内存?我在c1.xlarge示例上。如果我相信aws文档,那么设置mapred.child.java.opts=-xmx512m。
我怎么知道我需要多少内存?我可以尝试不同的尺寸,但我不知道我能处理的问题有多大。
如何更改内存使用情况?用不同类别的机器启动不同的工作流?是否尝试设置mapred.child.java.opts?
我的数据集似乎没有那么大。它是?
vectors.seq是一个稀疏向量集合,包含50225个向量(50225个与124420个其他相关的事物),总共有120万个关系。
这篇文章说的是set——方法mapreduce,我是,这是默认的。
这篇文章说所有的集群都保存在每个Map器和缩减器的内存中。这将是4*124420=498k的东西,这看起来并不太糟。
下面是堆栈:

13/04/19 18:12:53 INFO mapred.JobClient: Job complete: job_201304161435_7034
13/04/19 18:12:53 INFO mapred.JobClient: Counters: 7
13/04/19 18:12:53 INFO mapred.JobClient:   Job Counters 
13/04/19 18:12:53 INFO mapred.JobClient:     SLOTS_MILLIS_MAPS=28482
13/04/19 18:12:53 INFO mapred.JobClient:     Total time spent by all reduces waiting after reserving slots (ms)=0
13/04/19 18:12:53 INFO mapred.JobClient:     Total time spent by all maps waiting after reserving slots (ms)=0
13/04/19 18:12:53 INFO mapred.JobClient:     Rack-local map tasks=4
13/04/19 18:12:53 INFO mapred.JobClient:     Launched map tasks=4
13/04/19 18:12:53 INFO mapred.JobClient:     SLOTS_MILLIS_REDUCES=0
13/04/19 18:12:53 INFO mapred.JobClient:     Failed map tasks=1
Exception in thread "main" java.lang.InterruptedException: Cluster Iteration 1 failed processing s3://.../foo/fuzzyk2/clusters-1
        at org.apache.mahout.clustering.iterator.ClusterIterator.iterateMR(ClusterIterator.java:186)
        at org.apache.mahout.clustering.fuzzykmeans.FuzzyKMeansDriver.buildClusters(FuzzyKMeansDriver.java:288)
        at org.apache.mahout.clustering.fuzzykmeans.FuzzyKMeansDriver.run(FuzzyKMeansDriver.java:221)
        at org.apache.mahout.clustering.fuzzykmeans.FuzzyKMeansDriver.run(FuzzyKMeansDriver.java:110)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)
        at org.apache.mahout.clustering.fuzzykmeans.FuzzyKMeansDriver.main(FuzzyKMeansDriver.java:52)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.hadoop.util.ProgramDriver$ProgramDescription.invoke(ProgramDriver.java:68)
        at org.apache.hadoop.util.ProgramDriver.driver(ProgramDriver.java:139)
        at org.apache.mahout.driver.MahoutDriver.main(MahoutDriver.java:195)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:187)

下面是Map绘制者的部分日志:

2013-04-19 18:10:38,734 INFO org.apache.hadoop.fs.s3native.NativeS3FileSystem (main): Received IOException while reading '.../foo/vectors.seq', attempting to reopen.
java.net.SocketTimeoutException: Read timed out
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.read(SocketInputStream.java:129)
        at com.sun.net.ssl.internal.ssl.InputRecord.readFully(InputRecord.java:293)
        at com.sun.net.ssl.internal.ssl.InputRecord.readV3Record(InputRecord.java:405)
        at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:360)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:798)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:755)
        at com.sun.net.ssl.internal.ssl.AppInputStream.read(AppInputStream.java:75)
        at org.apache.http.impl.io.AbstractSessionInputBuffer.read(AbstractSessionInputBuffer.java:187)
        at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:164)
        at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:138)
        at java.io.FilterInputStream.read(FilterInputStream.java:116)
        at org.apache.hadoop.fs.s3native.NativeS3FileSystem$NativeS3FsInputStream.read(NativeS3FileSystem.java:291)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
        at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
        at java.io.DataInputStream.readFully(DataInputStream.java:178)
        at org.apache.hadoop.io.DataOutputBuffer$Buffer.write(DataOutputBuffer.java:63)
        at org.apache.hadoop.io.DataOutputBuffer.write(DataOutputBuffer.java:101)
        at org.apache.hadoop.io.SequenceFile$Reader.next(SequenceFile.java:2060)
        at org.apache.hadoop.io.SequenceFile$Reader.next(SequenceFile.java:2194)
        at org.apache.hadoop.mapreduce.lib.input.SequenceFileRecordReader.nextKeyValue(SequenceFileRecordReader.java:68)
        at org.apache.hadoop.mapred.MapTask$NewTrackingRecordReader.nextKeyValue(MapTask.java:540)
        at org.apache.hadoop.mapreduce.MapContext.nextKeyValue(MapContext.java:67)
        at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:143)
        at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:771)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:375)
        at org.apache.hadoop.mapred.Child$4.run(Child.java:255)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:396)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1132)
        at org.apache.hadoop.mapred.Child.main(Child.java:249)
2013-04-19 18:10:38,737 INFO org.apache.hadoop.fs.s3native.NativeS3FileSystem (main): Stream for key '.../foo/vectors.seq' seeking to position '62584'
2013-04-19 18:10:42,619 INFO org.apache.hadoop.mapred.TaskLogsTruncater (main): Initializing logs' truncater with mapRetainSize=-1 and reduceRetainSize=-1
2013-04-19 18:10:42,730 INFO org.apache.hadoop.io.nativeio.NativeIO (main): Initialized cache for UID to User mapping with a cache timeout of 14400 seconds.
2013-04-19 18:10:42,730 INFO org.apache.hadoop.io.nativeio.NativeIO (main): Got UserName hadoop for UID 106 from the native implementation
2013-04-19 18:10:42,733 FATAL org.apache.hadoop.mapred.Child (main): Error running child : java.lang.OutOfMemoryError: Java heap space
        at org.apache.mahout.math.map.OpenIntDoubleHashMap.rehash(OpenIntDoubleHashMap.java:434)
        at org.apache.mahout.math.map.OpenIntDoubleHashMap.put(OpenIntDoubleHashMap.java:387)
        at org.apache.mahout.math.RandomAccessSparseVector.setQuick(RandomAccessSparseVector.java:139)
        at org.apache.mahout.math.AbstractVector.assign(AbstractVector.java:560)
        at org.apache.mahout.clustering.AbstractCluster.observe(AbstractCluster.java:253)
        at org.apache.mahout.clustering.AbstractCluster.observe(AbstractCluster.java:241)
        at org.apache.mahout.clustering.AbstractCluster.observe(AbstractCluster.java:37)
        at org.apache.mahout.clustering.classify.ClusterClassifier.train(ClusterClassifier.java:158)
        at org.apache.mahout.clustering.iterator.CIMapper.map(CIMapper.java:55)
        at org.apache.mahout.clustering.iterator.CIMapper.map(CIMapper.java:18)
        at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:144)
        at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:771)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:375)
        at org.apache.hadoop.mapred.Child$4.run(Child.java:255)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:396)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1132)
        at org.apache.hadoop.mapred.Child.main(Child.java:249)
sz81bmfz

sz81bmfz1#

是的,你的记忆体快用完了。据我所知,“内存密集型工作负载”引导操作早就不受欢迎了,所以可能什么都不做。请看那一页的说明。
c1.xlarge 默认情况下,每个Map器应使用384mb。如果减去所有的jvm开销、拆分和合并的空间等,您可能就没有多少剩余空间了。
在引导操作中设置hadoop参数。如果使用控制台并设置 --site-key-value mapred.map.child.java.opts=-Xmx1g (如果您以编程方式执行此操作,并且遇到任何问题,请与我脱机联系;我可以提供myrrix的片段,因为它在推荐/集群作业中对emr集群进行了大量的调优以提高速度。)
你可以设置 mapred.map.java.child.opts 相反,要分别控制Map器和还原器。您还可以减少每台计算机的Map器数量以腾出更多空间,或者选择高内存示例。我通常发现 ml.xlarge 对于给定i/o价格比的emr来说是最优的,因为大多数作业最终都是i/o绑定的。

相关问题