lakshayg / tensorflow-build-archived

TensorFlow binaries supporting AVX, FMA, SSE

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sth strange about tensorflow 1.8

631068264 opened this issue · comments

commented

I use tf 1.8 osx 10.13.4 High Sierra

Python 3.6.5 (default, Mar 30 2018, 06:41:53) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin

First I got
Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
then I install https://github.com/lakshayg/tensorflow-build/raw/master/tensorflow-1.8.0-cp36-cp36m-macosx_10_7_x86_64.whl which fit my env.

The whl fix AVX2 FMA but when I run another code in pycharm ,sth strange happen I only get Process finished with exit code 132 (interrupted by signal 4: SIGILL) without any traceback

Finally because I use virtualenv , I remove it and install the requirements again. Run my code and get great result.So it's not the code error. After install the whl ,the code crash after open tf.session. But I don't know why.

code:

import numpy as np
import tensorflow as tf
from sklearn.datasets import fetch_california_housing
from sklearn.preprocessing import StandardScaler

housing = fetch_california_housing()
m, n = housing.data.shape
housing_data_plus_bias = np.c_[np.ones((m, 1)), housing.data]


scaler = StandardScaler()
scaled_housing_data = scaler.fit_transform(housing.data)
scaled_housing_data_plus_bias = np.c_[np.ones((m, 1)), scaled_housing_data]

n_epochs = 1000
learning_rate = 0.01

X = tf.constant(scaled_housing_data_plus_bias, dtype=tf.float32, name="X")
y = tf.constant(housing.target.reshape(-1, 1), dtype=tf.float32, name="y")
theta = tf.Variable(tf.random_uniform([n + 1, 1], -1.0, 1.0, seed=42), name="theta")
y_pred = tf.matmul(X, theta, name="predictions")
error = y_pred - y
mse = tf.reduce_mean(tf.square(error), name="mse")
gradients = 2 / m * tf.matmul(tf.transpose(X), error)
training_op = tf.assign(theta, theta - learning_rate * gradients)

init_var = tf.global_variables_initializer()

with tf.Session() as sess:
    # sess.run(init_var)
    init_var.run()
    for epoch in range(n_epochs):
        if epoch % 100 == 0:
            print("Epoch", epoch, "MSE =", mse.eval())
        sess.run(training_op)

    best_theta = theta.eval()

print(best_theta)

result:

2018-05-17 17:07:28.075427: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
Epoch 0 MSE = 2.7544262
Epoch 100 MSE = 0.632222
Epoch 200 MSE = 0.5727805
Epoch 300 MSE = 0.5585007
Epoch 400 MSE = 0.54907
Epoch 500 MSE = 0.542288
Epoch 600 MSE = 0.53737885
Epoch 700 MSE = 0.533822
Epoch 800 MSE = 0.5312425
Epoch 900 MSE = 0.5293705
[[ 2.06855226e+00]
 [ 7.74078071e-01]
 [ 1.31192386e-01]
 [-1.17845066e-01]
 [ 1.64778143e-01]
 [ 7.44081801e-04]
 [-3.91945131e-02]
 [-8.61356556e-01]
 [-8.23479712e-01]]

Process finished with exit code 0

Hi @631068264, sorry for the delay in responding. I have uploaded some new wheels for TF 1.8.0 on macOS, please give them a try. I guess this issue might be because the binary you are using is compiled with support for some other instructions as well which might not be supported on your hardware (just guessing).

Here are the links for TF v1.8.0
Python 2.7.15 - Download
Python 3.6.5 - Download

commented

Thanks your reply @lakshayg .It work well both in py2.7 and python3.6 by your new link