我遇到了错误" libhdfs.so:无法打开共享对象文件:没有这样的文件或目录" (在下面的堆栈跟踪)尝试运行python脚本,在存储在HDFS中的文件上调用Tensorflow阅读器。我在集群上的节点上运行脚本,该节点在执行时激活了virtualenv中的Tensorflow。我在执行之前设置了以下环境变量:
我按原样执行脚本:
这是脚本中的代码:
filename_queue = tf.train.string_input_producer([
"hdfs://hostname:port/user/hdfs/test.avro" ])
reader =
tf.WholeFileReader() key, value = reader.read(filename_queue)
with tf.Session() as sess:
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord)
sess.run([key,value])
coord.request_stop()
coord.join(threads)
下面是错误的堆栈跟踪。关于导致此错误的原因的任何想法都是值得赞赏的(我已经检查过LD_LIBRARY_PATH变量在执行之前有一个指向libhdfs.so文件的显式指针,无法弄清楚为什么它仍然无法找到该文件)。
Traceback (most recent call last):
File "TEST.py", line 25, in <module>
sess.run([key,value])
File "/home/username/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 767, in run
run_metadata_ptr)
File "/home/username/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 965, in _run
feed_dict_string, options, run_metadata)
File "/home/username/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1015, in _do_run
target_list, options, run_metadata)
File "/home/username/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1035, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.NotFoundError: libhdfs.so: cannot open shared object file: No such file or directory
[[Node: ReaderReadV2 = ReaderReadV2[_device="/job:localhost/replica:0/task:0/cpu:0"](WholeFileReaderV2, input_producer)]]
Caused by op u'ReaderReadV2', defined at:
File "TEST.py", line 19, in <module>
key, value = reader.read(filename_queue)
File "/home/username/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/io_ops.py", line 272, in read
return gen_io_ops._reader_read_v2(self._reader_ref, queue_ref, name=name)
File "/home/username/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/gen_io_ops.py", line 410, in _reader_read_v2
queue_handle=queue_handle, name=name)
File "/home/username/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 763, in apply_op
op_def=op_def)
File "/home/username/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2395, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/home/username/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1264, in __init__
self._traceback = _extract_stack()
NotFoundError (see above for traceback): libhdfs.so: cannot open shared object file: No such file or directory
答案 0 :(得分:0)
我也遇到过这个问题,我的解决方案是将此文件复制到:
$ HADOOP_HDFS_HOME / LIB /天然
如果您不知道此文件的位置,请执行以下命令以查找其位置:
sudo updatedb
locate libhdfs.so
这将为您提供文件的位置。接下来将文件复制到$ HADOOP_HDFS_HOME / lib / native:
cp locationOflibhdfs.so $HADOOP_HDFS_HOME/lib/native
注意:将locationOflibhdfs.so替换为libhdfs.so文件的位置。