背景
TensorFlow是深度学习领域的重要框架之一,但在使用过程中,可能会出现"NotFoundError: Could not find requested filesystem type "的错误。
错误描述
如下所示:
import tensorflow as tf
filename = '/data/test.tfrecord'
with tf.Session() as sess:
# Read the contents of the file
with tf.gfile.Open(filename, 'rb') as f:
data = f.read()
报错信息
NotFoundError: Could not find requested filesystem type ''
; No error logs detected; check stderr log for any TensorFlow error logs. FileNotFoundError: No such file or directory
解决办法
方法一:升级tensorflow版本(推荐)
应该先尝试更新 TensorFlow 至最新的版本,看能否解决问题,具体升级方法如下:
pip install tensorflow --upgrade
方法二:指定文件系统类型
import tensorflow as tf
filename = '/data/test.tfrecord'
file_system = tf.gfile.GFile(filename, 'rb').filesystem
with tf.Session() as sess:
# Read the contents of the file
with tf.gfile.Open(filename, 'rb', file_system=file_system) as f:
data = f.read()
方法三:显式使用文件系统
import tensorflow as tf
filename = '/data/test.tfrecord'
with tf.Session() as sess:
# Read the contents of the file
with tf.Graph().as_default(), tf.gfile.FastGFile(filename, 'rb') as f:
data = f.read()
以上是解决TensorFlow报"NotFoundError: Could not find requested filesystem type "的原因以及解决办法的完整攻略,希望对大家的使用有所帮助。
此文章发布者为:Python技术站作者[metahuber],转载请注明出处:http://pythonjishu.com/tensorflow-error-43/