我有一個程式,其中包含幾行使用 pyspark 的函式(其余的是普通的 Python)。
我的代碼中使用 pyspark 的部分:
X.to_csv(r'first.txt', header=None, index=None, sep=' ', mode='a')
# load the dataset
rows = np.loadtxt('first.txt')
rows = sc.parallelize(rows)
mat = RowMatrix(rows)
start_time = time.time() #to calculate the execution time of the function bellow
# compute SVD
svd = mat.computeSVD(20, computeU=True)
exemple_one = time.time() - start_time
print("---Exemple one : %s seconds ---" % (exemple_one))
first.txt是一個具有 2346x27 矩陣的文本檔案
0.0 0.0 ... 0.0 0.0 0.06664409020350408 0.0 0.0 0.0 0.0 0.0 .... 0 0.0 0.0
在集群上運行我的程式(作為 YARN)和使用(Python 命令)在我自己的機器上運行它有什么區別?這些差異是什么。
uj5u.com熱心網友回復:
您將獲得的結果沒有差異。
根據您的作業負載,您在本地運行時可能會遇到資源問題。
Spark 使您能夠使用資源管理器(例如 YARN)通過從資源管理器獲取執行器來擴展您的應用程式。
請查看 Spark 官方檔案中的以下鏈接,看看您是否有更具體的問題:
- 火花概述
- 集群模式概述
- 提交申請
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/477867.html
上一篇:顯示列的第一次出現
下一篇:在pyspark中拆分對應的列值
