运行BigDL文本分类器失败

时间:2018-02-22 19:55:45

标签: python apache-spark pyspark bigdl

当我使用单个节点PySpark运行BigDL(https://bigdl-project.github.io/0.4.0/)文本分类器示例(https://github.com/intel-analytics/BigDL/tree/master/pyspark/bigdl/models/textclassifier)时,出现以下错误。任何想法如何解决这个问题?

配置:

爪哇:

openjdk version "1.8.0_141"
OpenJDK Runtime Environment (build 1.8.0_141-8u141-b15-1~deb9u1-b15)
OpenJDK 64-Bit Server VM (build 25.141-b15, mixed mode)

PySpark:

dk@dk:~$ pyspark
Python 3.5.3 (default, Jan 19 2017, 14:11:04) 
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.
Using Spark's default log4j profile: org/apache/spark/log4j- defaults.properties
Setting default log level to "WARN".
To adjust logging level use sc.setLogLevel(newLevel). For SparkR, use setLogLevel(newLevel).
18/02/22 22:37:28 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
18/02/22 22:37:28 WARN Utils: Your hostname, dk resolves to a loopback address: 127.0.1.1; using 10.0.2.15 instead (on interface enp0s3)
18/02/22 22:37:28 WARN Utils: Set SPARK_LOCAL_IP if you need to bind to another address
18/02/22 22:37:45 WARN ObjectStore: Failed to get database global_temp, returning NoSuchObjectException
Welcome to
      ____              __
     / __/__  ___ _____/ /__
    _\ \/ _ \/ _ `/ __/  '_/
   /__ / .__/\_,_/_/ /_/\_\   version 2.2.1
      /_/

   Using Python version 3.5.3 (default, Jan 19 2017 14:11:04) SparkSession available as 'spark'.
   >>> 

运行示例的命令:

dk@dk:/usr/local/lib/python3.5/dist-packages/bigdl$ python models/textclassifier/textclassifier.py

错误:

Setting default log level to "WARN".
To adjust logging level use sc.setLogLevel(newLevel). For SparkR, use setLogLevel(newLevel).
2018-02-22 22:23:23 WARN  NativeCodeLoader:62 - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
2018-02-22 22:23:24 WARN  Utils:66 - Your hostname, dk resolves to a loopback address: 127.0.1.1; using 10.0.2.15 instead (on interface enp0s3)
2018-02-22 22:23:24 WARN  Utils:66 - Set SPARK_LOCAL_IP if you need to bind to another address
/usr/local/lib/python3.5/dist-packages/bigdl/util/engine.py:41: UserWarning: Find both SPARK_HOME and pyspark. You may need to check whether they match with each other. SPARK_HOME environment variable is set to: /opt/spark, and pyspark is found in: /usr/local/lib/python3.5/dist-packages/pyspark/__init__.py. If they are unmatched, please use one source only to avoid conflict. For example, you can unset SPARK_HOME and use pyspark only.
  warnings.warn(warning_msg)
Prepending /usr/local/lib/python3.5/dist-packages/bigdl/share/conf/spark-bigdl.conf to sys.path
Traceback (most recent call last):
  File "models/textclassifier/textclassifier.py", line 182, in <module>
    redire_spark_logs()
  File "/usr/local/lib/python3.5/dist-packages/bigdl/util/common.py", line 434, in redire_spark_logs
    callBigDlFunc(bigdl_type, "redirectSparkLogs", log_path)
  File "/usr/local/lib/python3.5/dist-packages/bigdl/util/common.py", line 552, in callBigDlFunc
    return callJavaFunc(sc, api, *args)
  File "/usr/local/lib/python3.5/dist-packages/bigdl/util/common.py", line 590, in callJavaFunc
    result = func(*args)
  File "/usr/local/lib/python3.5/dist-packages/py4j/java_gateway.py", line 1133, in __call__
    answer, self.gateway_client, self.target_id, self.name)
  File "/usr/local/lib/python3.5/dist-packages/py4j/protocol.py", line 319, in get_return_value
    format(target_id, ".", name), value)
py4j.protocol.Py4JJavaError: An error occurred while calling o28.redirectSparkLogs.
: java.nio.file.AccessDeniedException: /usr/local/lib/python3.5/dist-packages/bigdl/bigdl.log
    at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
    at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
    at java.nio.file.Files.newByteChannel(Files.java:361)
    at java.nio.file.Files.createFile(Files.java:632)
    at com.intel.analytics.bigdl.utils.LoggerFilter$.getLogFile$1(LoggerFilter.scala:101)
    at com.intel.analytics.bigdl.utils.LoggerFilter$.redirectSparkInfoLogs(LoggerFilter.scala:111)
    at com.intel.analytics.bigdl.python.api.PythonBigDL.redirectSparkLogs(PythonBigDL.scala:2419)
    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)

1 个答案:

答案 0 :(得分:1)

python脚本试图在bigdl.log中创建一个/usr/local/lib/python3.5/dist-packages/bigdl/bigdl.log文件,该文件是linux中受保护的目录,只能通过root访问访问。

您可以指定redire_spark_logs函数的日志文件路径,例如redire_spark_logs(log_path='/home/bigdl-projects')。查看here了解更多详情。