1. 程式人生 > 實用技巧 >TensorFlow在樹莓派4B上安裝後報錯HadoopFileSystem load error的解決方法

TensorFlow在樹莓派4B上安裝後報錯HadoopFileSystem load error的解決方法

問題重現

在樹莓派上使用TensorFlow官方的命令安裝完TensorFlow後用python測試是否安裝成功:

$ python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

結果報出瞭如下錯誤:

E tensorflow/core/platform/hadoop/hadoop_file_system.cc:132] HadoopFileSystem load error: libhdfs.so: cannot open shared object file: No such file or directory

問題原因

不能安裝1.14.0版本的Tensorflow,需要安裝2.x.x或更高版本的TensorFlow

解決方案

不知道安裝了什麼版本的Tensorflow可以用以下命令檢視安裝的包

sudo pip3 list

然後解除安裝1.14.0版本的Tensorflow

sudo pip3 uninstall tensorflow-estimator
sudo pip3 uninstall tensorflow
sudo pip3 uninstall tensorboard

再安裝2.x.x版本的TensorFlow(以2.3.0為例)

sudo pip3 install https://
github.com/lhelontra/tensorflow-on-arm/releases/download/v2.3.0/tensorflow-2.3.0-cp37-none-linux_armv7l.whl

如果想安裝最新版本的Tensorflow,可以檢視這個github倉庫Release:https://github.com/lhelontra/tensorflow-on-arm/releases

根據你的樹莓派版本找到對應的Assets,右鍵複製連結然後貼上到命令sudo pip3 install後面

安裝完成後最後測試是否成功:

python3 -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))
" tf.Tensor(267.6587, shape=(), dtype=float32)

引用的github issue comment: https://github.com/tensorflow/tensorflow/issues/36141#issuecomment-625958459