如何在 ubuntu20 上以 theano 为后端的 termux 运行 keras
Posted
技术标签:
【中文标题】如何在 ubuntu20 上以 theano 为后端的 termux 运行 keras【英文标题】:How to run keras on ubuntu20 on termux with backend as theano 【发布时间】:2021-09-09 23:22:40 【问题描述】:我尝试在 Pydroid 3 (android) 上安装 theano 和 keras,我成功了,但是在运行 keras 时,theano 不是 keras 的后端,所以我在 termux 上安装了 ubuntu 20,并使用以下命令安装了 keras 和 theano:-
apt install python3-keras --no-install-recommends && apt install python3-theano --no-install-recommends
它已成功安装,当我想要后端的东西为 theano
时,我搜索了 ~/.keras/keras.json
但它不存在所以无论如何我想检查它所以我运行它给了我以下错误:-
root@localhost~# python3 testkeras.py
[localhost:21091] opal_ifinit: ioctl(SIOCGIFHWADDR) failed with errno=13
[localhost:21092] opal_ifinit: ioctl(SIOCGIFHWADDR) failed with errno=13
[localhost:21092] pmix_ifinit: ioctl(SIOCGIFHWADDR) failed with errno=13
[localhost:21092] oob_tcp: problems getting address for index 88256 (kernel index -1)
-------------------------------------------------------------------------- No network interfaces were found for out-of-band communications. We require
at least one available network for out-of-band messaging.
--------------------------------------------------------------------------
[localhost:21091] [[INVALID],INVALID] ORTE_ERROR_LOG: Unable to start a daemon on the local node in file ess_singleton_module.c at line 716
[localhost:21091] [[INVALID],INVALID] ORTE_ERROR_LOG: Unable to start a daemon on the local node in file ess_singleton_module.c at line 172 -------------------------------------------------------------------------- It looks like orte_init failed for some reason; your parallel process is
likely to abort. There are many reasons that a parallel process can
fail during orte_init; some of which are due to configuration or
environment problems. This failure appears to be an internal failure;
here's some additional information (which may only be relevant to an
Open MPI developer):
orte_ess_init failed
--> Returned value Unable to start a daemon on the local node (-127) instead of ORTE_SUCCESS
--------------------------------------------------------------------------
--------------------------------------------------------------------------
It looks like MPI_INIT failed for some reason; your parallel process is
likely to abort. There are many reasons that a parallel process can
fail during MPI_INIT; some of which are due to configuration or environment
problems. This failure appears to be an internal failure; here's some
additional information (which may only be relevant to an Open MPI
developer):
ompi_mpi_init: ompi_rte_init failed
--> Returned "Unable to start a daemon on the local node" (-127) instead of "Success" (0)
--------------------------------------------------------------------------
*** An error occurred in MPI_Init_thread
*** on a NULL communicator
*** MPI_ERRORS_ARE_FATAL (processes in this communicator will now abort,
*** and potentially your MPI job)
[localhost:21091] Local abort before MPI_INIT completed completed successfully, but am not able to aggregate error messages, and not able to guarantee that all other processes were killed!
1.) 我想知道问题出在哪里。
2.) 欢迎提出建议。
如果你们想知道我运行的代码
import numpy as np
from keras.models import Sequential
from keras.layers import Dense, Dropout
这是我安装的模块:
Package Version
------------------- -------
decorator 4.4.2 h5py 2.10.0
Keras 2.2.4
Keras-Applications 1.0.6
Keras-Preprocessing 1.0.5
mpi4py 3.0.3
numpy 1.17.4
pip 20.0.2 PyYAML 5.3.1 scipy 1.3.3
setuptools 45.2.0
six 1.14.0
Theano 1.0.4
wheel 0.34.2
我是这个机器学习领域的新手
系统上的一些其他信息
.-/+oossssoo+/-.
`:+ssssssssssssssssss+:`
-+ssssssssssssssssssyyssss+-
.ossssssssssssssssssdMMMNysssso.
/ssssssssssshdmmNNmmyNMMMMhssssss/ root@localhost
+ssssssssshmydMMMMMMMNddddyssssssss+ --------------
/sssssssshNMMMyhhyyyyhmNMMMNhssssssss/ OS: Ubuntu 20.04 LTS focal aarch64
.ssssssssdMMMNhsssssssssshNMMMdssssssss. Kernel: 4.4.147+
+sssshhhyNMMNyssssssssssssyNMMMysssssss+ Uptime: 18805 days, 10 hours, 9 min
ossyNMMMNyMMhsssssssssssssshmmmhssssssso Packages: 202 (dpkg)
ossyNMMMNyMMhsssssssssssssshmmmhssssssso Shell: bash 5.0.16
+sssshhhyNMMNyssssssssssssyNMMMysssssss+ Terminal: proot
.ssssssssdMMMNhsssssssssshNMMMdssssssss. CPU: Unisoc SC9863a (8) @ 1.200GHz
/sssssssshNMMMyhhyyyyhdNMMMNhssssssss/ Memory: 957MiB / 1819MiB
+sssssssssdmydMMMMMMMMddddyssssssss+
/ssssssssssshdmNNNNmyNMMMMhssssss/
.ossssssssssssssssssdMMMNysssso.
-+sssssssssssssssssyyyssss+-
`:+ssssssssssssssssss+:`
.-/+oossssoo+/-.
【问题讨论】:
那么 testkeras.py 文件只包含那些导入?如果你只是打开一个 python shell,然后导入 keras 怎么办?这种情况下的输出是什么? @Dr.Snoopy 是的,我会试试的。 @Dr.Snoopy 它给了我相同的输出 这些错误对我来说毫无意义,我不明白为什么这里涉及 MPI,这就是我要求提供确切代码的原因。您的平台也存在不一致,例如正常运行时间不能是 18805 天(即超过 50 年)。 【参考方案1】:谢谢史努比博士,我终于让它正常工作了。但是我不得不删除操作系统并使用来自termux的命令apt install proot-distro
重新安装它,但我认为真正的问题是命令
apt install python3-keras --no-install-recommends
正如你所说的,存在一些不满意的依赖关系或平台不一致。
好的,最后要完成它的工作步骤
1.在termux中输入以下命令apt install proot-distro && proot-distro install ubuntu-18.04 && apt install python3-keras
2. 然后用最喜欢的文本编辑器编辑我本例使用vim的文件vim .keras/keras.json
文件如下所示:
"floatx": "float32",
"epsilon": 1e-07,
"backend": "tensorflow",
"image_data_format": "channels_last"
并在我的情况下将后端的值更改为 theano 我广告 theano 文件应如下所示:
"floatx": "float32",
"epsilon": 1e-07,
"backend": "theano",
"image_data_format": "channels_last"
然后保存文件。进入python交互模式进行测试,输入import keras
输出应该是Using Theano as Backend
我认为这应该可以帮助到那里的人。
【讨论】:
以上是关于如何在 ubuntu20 上以 theano 为后端的 termux 运行 keras的主要内容,如果未能解决你的问题,请参考以下文章
在ubuntu安装python, theano, keras , Spearmint, Mongodb
在 AWS g2 上的 Ubuntu 14.04 上使用带 GPU 的 Theano
Ubuntu19 安装Theano出现“No module named ‘theano.compat.six’”