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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM