All of lore.kernel.org
 help / color / mirror / Atom feed
From: "hongxu" <hongxu.jia@windriver.com>
To: randy.macleod@windriver.com, philip@balister.org,
	akuster808@gmail.com, marek.belisko@gmail.com,
	yocto@yoctoproject.org
Subject: Review request 0/25:[meta-tensorflow] upgrade tensorflow 1.13.1 -> 2.4.0.rc4
Date: Wed, 16 Dec 2020 21:07:57 +0800	[thread overview]
Message-ID: <20201216130822.28476-1-hongxu.jia@windriver.com> (raw)

# Build and Run
## 1. Clone away
```
$ mkdir <ts-project>
$ cd <ts-project>
$ git clone git://git.yoctoproject.org/meta-tensorflow
$ git clone git://git.openembedded.org/meta-openembedded
$ git clone git://git.openembedded.org/openembedded-core oe-core
$ cd oe-core
$ git clone git://git.openembedded.org/bitbake
```

## 2. Prepare build
```
$ . <ts-project>/oe-core/oe-init-build-env <build>

# Build qemux86-64 which runqemu supports kvm.
$ echo 'MACHINE = "qemux86-64"' >> conf/local.conf

$ echo 'IMAGE_INSTALL_append = " tensorflow"' >> conf/local.conf

Edit conf/bblayers.conf to include other layers
BBLAYERS ?= " \ 
    <ts-project>/oe-core/meta \
    <ts-project>/meta-openembedded/meta-python \
    <ts-project>/meta-openembedded/meta-oe \
    <ts-project>/meta-tensorflow \
"
```
## 3. Build image                                                                                                                      
```                                                                                                                                    
cd <build>                                                                                                                             
$ bitbake core-image-minimal                                                                                                           
```

## 4. Start qemu with slrip + kvm + 5GB memory:
```
$ runqemu qemux86-64 core-image-minimal slirp kvm qemuparams="-m 5120"
```

## 5. Verify the install
```
root@qemux86-64:~# python3 -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
tf.Tensor(-3304.6208, shape=(), dtype=float32)

## 6. Run tutorial case
### Refer: https://www.tensorflow.org/tutorials
```
root@qemux86-64:~# cat >code-v2.py <<ENDOF
import tensorflow as tf
mnist = tf.keras.datasets.mnist

(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0

model = tf.keras.models.Sequential([
  tf.keras.layers.Flatten(input_shape=(28, 28)),
  tf.keras.layers.Dense(128, activation='relu'),
  tf.keras.layers.Dropout(0.2),
  tf.keras.layers.Dense(10)
])

predictions = model(x_train[:1]).numpy()
tf.nn.softmax(predictions).numpy()
loss_fn = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True)
loss_fn(y_train[:1], predictions).numpy()

model.compile(optimizer='adam',
              loss=loss_fn,
              metrics=['accuracy'])
model.fit(x_train, y_train, epochs=5)
model.evaluate(x_test,  y_test, verbose=2)

probability_model = tf.keras.Sequential([
  model,
  tf.keras.layers.Softmax()
])
probability_model(x_test[:5])

ENDOF

root@qemux86-64:~# python3 ./code-v2.py
2020-12-15 08:16:44.171593: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:116] None of the MLIR optimization passes are enabled (registered 2)
2020-12-15 08:16:44.184464: I tensorflow/core/platform/profile_utils/cpu_utils.cc:112] CPU Frequency: 3099995000 Hz
Epoch 1/5
1875/1875 [==============================] - 14s 7ms/step - loss: 0.4833 - accuracy: 0.8595
Epoch 2/5
1875/1875 [==============================] - 13s 7ms/step - loss: 0.1549 - accuracy: 0.9558
Epoch 3/5
1875/1875 [==============================] - 13s 7ms/step - loss: 0.1135 - accuracy: 0.9651
Epoch 4/5
1875/1875 [==============================] - 13s 7ms/step - loss: 0.0889 - accuracy: 0.9729
Epoch 5/5
1875/1875 [==============================] - 13s 7ms/step - loss: 0.0741 - accuracy: 0.9777
313/313 - 1s - loss: 0.0757 - accuracy: 0.9757
```
## 7. TensorFlow/TensorFlow Lite C++ Image Recognition Demo                                                                            
```                                                                                                                                    
root@qemux86-64:~# time label_image                                                                                                    
2020-12-15 08:18:34.853885: I tensorflow/core/platform/profile_utils/cpu_utils.cc:112] CPU Frequency: 3099995000 Hz                    
2020-12-15 08:18:41.565167: I tensorflow/examples/label_image/main.cc:252] military uniform (653): 0.834306                            
2020-12-15 08:18:41.567874: I tensorflow/examples/label_image/main.cc:252] mortarboard (668): 0.0218696                                
2020-12-15 08:18:41.568936: I tensorflow/examples/label_image/main.cc:252] academic gown (401): 0.0103581                              
2020-12-15 08:18:41.569985: I tensorflow/examples/label_image/main.cc:252] pickelhaube (716): 0.00800819                               
2020-12-15 08:18:41.571025: I tensorflow/examples/label_image/main.cc:252] bulletproof vest (466): 0.00535086                          
                                                                                                                                       
real    0m7.178s                                                                                                                       
user    0m6.101s                                                                                                                       
sys 0m0.893s                                                                                                                           
                                                                                                                                       
root@qemux86-64:~# time label_image.lite                                                                                               
INFO: Loaded model /usr/share/label_image/mobilenet_v1_1.0_224_quant.tflite                                                            
INFO: resolved reporter
INFO: invoked
INFO: average time: 213.584 ms
INFO: 0.780392: 653 military uniform
INFO: 0.105882: 907 Windsor tie
INFO: 0.0156863: 458 bow tie
INFO: 0.0117647: 466 bulletproof vest
INFO: 0.00784314: 835 suit

real    0m0.233s
user    0m0.216s
sys 0m0.012s

             reply	other threads:[~2020-12-16 13:08 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-16 13:07 hongxu [this message]
2020-12-16 13:07 ` [meta-tensorflow][PATCH 1/25] openjdk-8-native: 212b04 -> 275b01 hongxu
2020-12-16 16:49   ` [yocto] " Kent Dorfman
2020-12-16 13:07 ` [meta-tensorflow][PATCH 2/25] bazel-native: 0.21.0 -> 3.1.0 hongxu
2020-12-16 13:08 ` [meta-tensorflow][PATCH 3/25] tensorflow: 1.13.0 -> 2.4.0 hongxu
2020-12-16 13:08 ` [meta-tensorflow][PATCH 4/25] add python3-gast 0.3.3 hongxu
2020-12-16 13:08 ` [meta-tensorflow][PATCH 5/25] python3-opt-einsum: add 3.3.0 hongxu
2020-12-16 13:08 ` [meta-tensorflow][PATCH 6/25] python3-google-pasta: add 0.2.0 hongxu
2020-12-16 13:08 ` [meta-tensorflow][PATCH 7/25] python3-astunparse: add 1.6.3 hongxu
2020-12-16 13:08 ` [meta-tensorflow][PATCH 8/25] tensorflow-estimator: 1.13 -> 2.4 hongxu
2021-01-04 10:30   ` Marek Belisko
2021-01-07 17:51     ` [yocto] " Randy MacLeod
2021-01-07 18:47       ` Marek Belisko
2021-01-07 20:47         ` Randy MacLeod
2021-01-25 18:57           ` Marek Belisko
2021-01-25 20:46             ` Randy MacLeod
2020-12-16 13:08 ` [meta-tensorflow][PATCH 9/25] bazel-native/bazel.bbclass: use default Bazel toolchain to build Yocto native tools hongxu
2020-12-16 13:08 ` [meta-tensorflow][PATCH 10/25] bazel-native/bazel.bbclass: replace deprecated --local_resources hongxu
2020-12-16 13:08 ` [meta-tensorflow][PATCH 11/25] tensorflow: update cross compile support hongxu
2020-12-16 13:08 ` [meta-tensorflow][PATCH 12/25] tensorflow: fix Multiple shlib providers for libtensorflow_framework.so hongxu
2020-12-16 13:08 ` [meta-tensorflow][PATCH 13/25] classes/bazel.bbclass: clean up bazel files before do_clean hongxu
2020-12-16 13:08 ` [meta-tensorflow][PATCH 14/25] python3-google-auth: 1.6.3 -> 1.24.0 hongxu
2020-12-16 13:08 ` [meta-tensorflow][PATCH 15/25] python3-google-auth-oauthlib: add version 0.4.2 hongxu
2020-12-16 13:08 ` [meta-tensorflow][PATCH 16/25] python3-pyasn1: add 0.4.8 hongxu
2020-12-16 13:08 ` [meta-tensorflow][PATCH 17/25] python3-pyasn1-modules: add version 0.2.8 hongxu
2020-12-16 13:08 ` [meta-tensorflow][PATCH 18/25] tensorboard: 1.12.2 -> 2.4 hongxu
2020-12-16 13:08 ` [meta-tensorflow][PATCH 19/25] tensorflow: clean up CROSSTOOL.tpl hongxu
2020-12-16 13:08 ` [meta-tensorflow][PATCH 20/25] bazel-native: 3.1.0 -> 3.7.1 hongxu
2020-12-16 13:08 ` [meta-tensorflow][PATCH 21/25] add classes/bazel-base.bbclass and imporve classes/bazel-base.bbclass hongxu
2020-12-16 13:08 ` [meta-tensorflow][PATCH 22/25] bazel-native/bazel.bbclass: support bazel build without limitation hongxu
2020-12-16 13:08 ` [meta-tensorflow][PATCH 23/25] BUILD.md: update quick start for tensorflow 2 hongxu
2020-12-16 13:08 ` [meta-tensorflow][PATCH 24/25] tensorflow: split sub packages hongxu
2020-12-16 13:08 ` [meta-tensorflow][PATCH 25/25] update LIMITATION.md hongxu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201216130822.28476-1-hongxu.jia@windriver.com \
    --to=hongxu.jia@windriver.com \
    --cc=akuster808@gmail.com \
    --cc=marek.belisko@gmail.com \
    --cc=philip@balister.org \
    --cc=randy.macleod@windriver.com \
    --cc=yocto@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.