gpt4 book ai didi

java - systemML :'JavaPackage' 不可调用。当我使用 MLContext 时

转载 作者:行者123 更新时间:2023-12-02 12:00:56 25 4
gpt4 key购买 nike

我按照website中的教程进行操作,我选择“示例笔记本”--深度学习图像分类,(look here),当我运行
ml = MLContext(sc)
,出现错误如下:

---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
~/.local/lib/python3.5/site-packages/systemml/classloader.py in createJavaObject(sc, obj_type)
86 try:
---> 87 return _createJavaObject(sc, obj_type)
88 except (py4j.protocol.Py4JError, TypeError):

~/.local/lib/python3.5/site-packages/systemml/classloader.py in _createJavaObject(sc, obj_type)
46 if obj_type == 'mlcontext':
---> 47 return sc._jvm.org.apache.sysml.api.mlcontext.MLContext(sc._jsc)
48 elif obj_type == 'dummy':

TypeError: 'JavaPackage' object is not callable

During handling of the above exception, another exception occurred:

Py4JJavaError Traceback (most recent call last)
<ipython-input-5-724894051c3e> in <module>()
----> 1 ml = MLContext(sc)

~/.local/lib/python3.5/site-packages/systemml/mlcontext.py in __init__(self, sc)
697 raise ValueError("Expected sc to be a SparkContext or SparkSession, got " % str(type(sc)))
698 self._sc = sc
--> 699 self._ml = createJavaObject(sc, 'mlcontext')
700
701 def __repr__(self):

~/.local/lib/python3.5/site-packages/systemml/classloader.py in createJavaObject(sc, obj_type)
92 # First load SystemML
93 jar_file_name = _getJarFileName(sc, '')
---> 94 x = _getLoaderInstance(sc, jar_file_name, 'org.apache.sysml.utils.SystemMLLoaderUtils', hint + 'SystemML.jar')
95 x.loadSystemML(jar_file_name)
96 try:

~/.local/lib/python3.5/site-packages/systemml/classloader.py in _getLoaderInstance(sc, jar_file_name, className, hint)
69 jar_file_url_arr[0] = jar_file_url
70 url_class_loader = sc._jvm.java.net.URLClassLoader(jar_file_url_arr, sc._jsc.getClass().getClassLoader())
---> 71 c1 = sc._jvm.java.lang.Class.forName(className, True, url_class_loader)
72 return c1.newInstance()
73 else:

/usr/local/lib/python3.5/dist-packages/py4j/java_gateway.py in __call__(self, *args)
1158 answer = self.gateway_client.send_command(command)
1159 return_value = get_return_value(
-> 1160 answer, self.gateway_client, self.target_id, self.name)
1161
1162 for temp_arg in temp_args:

~/software/spark-2.1.0-bin-hadoop2.7/python/pyspark/sql/utils.py in deco(*a, **kw)
61 def deco(*a, **kw):
62 try:
---> 63 return f(*a, **kw)
64 except py4j.protocol.Py4JJavaError as e:
65 s = e.java_exception.toString()

/usr/local/lib/python3.5/dist-packages/py4j/protocol.py in get_return_value(answer, gateway_client, target_id, name)
318 raise Py4JJavaError(
319 "An error occurred while calling {0}{1}{2}.\n".
--> 320 format(target_id, ".", name), value)
321 else:
322 raise Py4JError(

Py4JJavaError: An error occurred while calling z:java.lang.Class.forName.
: java.lang.ClassNotFoundException: org.apache.sysml.utils.SystemMLLoaderUtils
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
at py4j.Gateway.invoke(Gateway.java:280)
at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
at py4j.commands.CallCommand.execute(CallCommand.java:79)
at py4j.GatewayConnection.run(GatewayConnection.java:214)
at java.lang.Thread.run(Thread.java:748)

好像找不到SystemML.jar?我下载的 systemml 二进制文件可能包含此文件。但我不知道我能做什么。谢谢!谢谢!!!

最佳答案

正如您正确指出的那样,发生错误是因为找不到 SystemML 类。有两种方法可以解决这个问题:

  1. (推荐)我建议不要下载 python 文件,而是通过 pip 安装 SystemML:pip install systemml(已发布版本)或 pip install https://sparktc。 ibmcloud.com/repo/latest/systemml-1.0.0-SNAPSHOT-python.tar.gz(最新代码)。这负责包装必要的 jar 。

  2. 如果您更喜欢使用下载的 python 文件,那么您必须提供 SystemML.jarsystemml-*-extra.jar通过 pyspark 的 --driver-class-path 选项。

关于java - systemML :'JavaPackage' 不可调用。当我使用 MLContext 时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47256639/

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