question:
I've built a python (3.5) environment on the development board, and it's OK to run the simple tensorflow (version 1.8.0 & 1.12.1) code, but as long as I train the model, it report an error that illegal instruction, and the code is OK on the PC ! When I restore the trained model from PC, it will also report the error. I have checked many websites, but there is no similar problem. How can I solve this error?
举个简单的例子说明,代码如下:
import tensorflow as tf
import numpy as np
x = np.float32(np.random.rand(100, 1))
y = np.dot(x, 0.5) + 0.7
b = tf.Variable(np.float32(0.3))
a = tf.Variable(np.float32(0.3))
y_value = tf.multiply(x, a) + b
loss = tf.reduce_mean(tf.square(y_value - y))
optimizer = tf.train.GradientDescentOptimizer(0.5)
train = optimizer.minimize(loss)
init = tf.global_variables_initializer()
sess = tf.Session()
sess.run(init)
for step in range(0, 100):
print(step)
sess.run(train)
if step % 10 == 0:
print(step, sess.run(loss), sess.run(a), sess.run(b))
在PC端运行是完全没有问题的, ,,在arm 上运行,出现:
0
Illegal instruction
也就是在sess.run(train)报错,,,,sess.run() 函数在arm上,我测试过,函数可以运行,那就是梯度下降不能正常运行;出现了非法指令的问题;
arm CPU相关信息:
root@EmbedSky-Board:/xzy/mix# lscpu
Architecture: armv7l
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 1
Core(s) per socket: 4
Socket(s): 1
Model name: ARMv7 Processor rev 10 (v7l)
CPU max MHz: 996.0000
CPU min MHz: 792.0000
root@EmbedSky-Board:/xzy/mix# cat /proc/cpuinfo
processor : 0
model name : ARMv7 Processor rev 10 (v7l)
BogoMIPS : 6.00
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpd32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x2
CPU part : 0xc09
CPU revision : 10
信息补充:arm来自于TQIMX6Q,armv7, NXP i.MX6Q Cortex-A9 4x1GHz, tensorflow 来自于https://www.piwheels.org/simple/;这是问题真是实在是太奇怪了!