<p dir="auto"><strong>System information</strong></p>
<ul dir="auto">
<li>OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 16.04)</li>
<li>Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: all</li>
<li>TensorFlow installed from (source or binary):source</li>
<li>TensorFlow version:1.10</li>
<li>Python version:.3.6</li>
<li>Installed using virtualenv? pip? conda?:conda</li>
<li>Bazel version (if compiling from source):1.15</li>
<li>GCC/Compiler version (if compiling from source):5.4</li>
<li>CUDA/cuDNN version:8.0</li>
<li>GPU model and memory:16GB</li>
</ul>
<p dir="auto">I build the libtensorflowLite.so following the <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="327655172" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/19642" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/19642/hovercard?comment_id=422697028&amp;comment_type=issue_comment" href="https://github.com/tensorflow/tensorflow/issues/19642#issuecomment-422697028">#19642 (comment)</a>, and i can use it in the android project . But the .so of the  libtensorflowLite.so is about 3.7M. From the document ,it should be hundreds of KB.<br>
Here is my build commit:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="bazel build -c opt //tensorflow/contrib/lite:libtensorflowLite.so 
 --crosstool_top=//external:android/crosstool 
 --cpu=arm64-v8a
 --host_crosstool_top=@bazel_tools//tools/cpp:toolchain
 --cxxopt=&quot;-std=c++11&quot; 
 --verbose_failures
"><pre class="notranslate"><code class="notranslate">bazel build -c opt //tensorflow/contrib/lite:libtensorflowLite.so 
 --crosstool_top=//external:android/crosstool 
 --cpu=arm64-v8a
 --host_crosstool_top=@bazel_tools//tools/cpp:toolchain
 --cxxopt="-std=c++11" 
 --verbose_failures

</code></pre></div>
<p dir="auto">So, could someone helps me, how can I reduce the size of tflite library?</p>
<p dir="auto">Hi,<br>
I'm testing the tf.contrib.learn example in the<br>
<a href="https://www.tensorflow.org/get_started/tflearn" rel="nofollow">https://www.tensorflow.org/get_started/tflearn</a><br>
But when I executing the statement:<br>
classifier.fit(input_fn=get_train_inputs, steps=2000)<br>
I get the following error logs:</p>
<p dir="auto">WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/head.py:1362: scalar_summary (from tensorflow.python.ops.logging_ops) is deprecated and will be removed after 2016-11-30.<br>
Instructions for updating:<br>
Please switch to tf.summary.scalar. Note that tf.summary.scalar uses the node name instead of the tag. This means that TensorFlow will automatically de-duplicate summary names based on the scope they are created in. Also, passing a tensor or list of tags to a scalar summary op is no longer supported.<br>
INFO:tensorflow:Create CheckpointSaverHook.<br>
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.<br>
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.<br>
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.<br>
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.<br>
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.<br>
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.<br>
I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:910] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero<br>
I tensorflow/core/common_runtime/gpu/gpu_device.cc:885] Found device 0 with properties:<br>
name: GeForce GTX 960M<br>
major: 5 minor: 0 memoryClockRate (GHz) 1.176<br>
pciBusID 0000:01:00.0<br>
Total memory: 3.95GiB<br>
Free memory: 3.24GiB<br>
I tensorflow/core/common_runtime/gpu/gpu_device.cc:906] DMA: 0<br>
I tensorflow/core/common_runtime/gpu/gpu_device.cc:916] 0:   Y<br>
I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -&gt; (device: 0, name: GeForce GTX 960M, pci bus id: 0000:01:00.0)<br>
E tensorflow/stream_executor/cuda/cuda_driver.cc:1002] failed to allocate 3.95G (4240965632 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY<br>
E tensorflow/stream_executor/cuda/cuda_driver.cc:1002] failed to allocate 3.55G (3816868864 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY<br>
E tensorflow/stream_executor/cuda/cuda_blas.cc:372] failed to create cublas handle: CUBLAS_STATUS_NOT_INITIALIZED<br>
W tensorflow/stream_executor/stream.cc:1390] attempting to perform BLAS operation using StreamExecutor without BLAS support<br>
Traceback (most recent call last):<br>
File "", line 2, in <br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/util/deprecation.py", line 280, in new_func<br>
return func(*args, **kwargs)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 426, in fit<br>
loss = self._train_model(input_fn=input_fn, hooks=hooks)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 984, in _train_model<br>
_, loss = mon_sess.run([model_fn_ops.train_op, model_fn_ops.loss])<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/monitored_session.py", line 462, in run<br>
run_metadata=run_metadata)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/monitored_session.py", line 786, in run<br>
run_metadata=run_metadata)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/monitored_session.py", line 744, in run<br>
return self._sess.run(*args, **kwargs)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/monitored_session.py", line 891, in run<br>
run_metadata=run_metadata)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/monitored_session.py", line 744, in run<br>
return self._sess.run(*args, **kwargs)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 767, in run<br>
run_metadata_ptr)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 965, in _run<br>
feed_dict_string, options, run_metadata)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1015, in _do_run<br>
target_list, options, run_metadata)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1035, in _do_call<br>
raise type(e)(node_def, op, message)<br>
tensorflow.python.framework.errors_impl.InternalError: Blas SGEMM launch failed : a.shape=(120, 4), b.shape=(4, 10), m=120, n=10, k=4<br>
[[Node: dnn/hiddenlayer_0/MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/gpu:0"](dnn/input_from_feature_columns/input_from_feature_columns/concat, dnn/hiddenlayer_0/weights)]]</p>
<p dir="auto">Caused by op u'dnn/hiddenlayer_0/MatMul', defined at:<br>
File "", line 2, in <br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/util/deprecation.py", line 280, in new_func<br>
return func(*args, **kwargs)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 426, in fit<br>
loss = self._train_model(input_fn=input_fn, hooks=hooks)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 934, in _train_model<br>
model_fn_ops = self._call_legacy_get_train_ops(features, labels)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 1003, in _call_legacy_get_train_ops<br>
train_ops = self._get_train_ops(features, labels)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 1162, in _get_train_ops<br>
return self._call_model_fn(features, labels, model_fn_lib.ModeKeys.TRAIN)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 1133, in _call_model_fn<br>
model_fn_results = self._model_fn(features, labels, **kwargs)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/dnn.py", line 143, in _dnn_model_fn<br>
scope=scope)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 177, in func_with_args<br>
return func(*args, **current_args)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/layers/python/layers/layers.py", line 1409, in fully_connected<br>
outputs = layer.apply(inputs)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/layers/base.py", line 303, in apply<br>
return self.<strong>call</strong>(inputs, **kwargs)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/layers/base.py", line 273, in <strong>call</strong><br>
outputs = self.call(inputs, **kwargs)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/layers/core.py", line 145, in call<br>
outputs = standard_ops.matmul(inputs, self.kernel)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/math_ops.py", line 1855, in matmul<br>
a, b, transpose_a=transpose_a, transpose_b=transpose_b, name=name)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_math_ops.py", line 1454, in _mat_mul<br>
transpose_b=transpose_b, name=name)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 763, in apply_op<br>
op_def=op_def)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2395, in create_op<br>
original_op=self._default_original_op, op_def=op_def)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1264, in <strong>init</strong><br>
self._traceback = _extract_stack()</p>
<p dir="auto">InternalError (see above for traceback): Blas SGEMM launch failed : a.shape=(120, 4), b.shape=(4, 10), m=120, n=10, k=4<br>
[[Node: dnn/hiddenlayer_0/MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/gpu:0"](dnn/input_from_feature_columns/input_from_feature_columns/concat, dnn/hiddenlayer_0/weights)]]</p>
<blockquote>
<blockquote>
<blockquote>
<h1 dir="auto">Define the test inputs</h1>
</blockquote>
</blockquote>
</blockquote>
<p dir="auto">... def get_test_inputs():<br>
...     x = tf.constant(test_set.data)<br>
...     y = tf.constant(test_set.target)<br>
...     return x, y<br>
...</p>
<blockquote>
<blockquote>
<blockquote>
<p dir="auto">classifier.fit(input_fn=get_train_inputs, steps=2000)<br>
WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/head.py:1362: scalar_summary (from tensorflow.python.ops.logging_ops) is deprecated and will be removed after 2016-11-30.<br>
Instructions for updating:<br>
Please switch to tf.summary.scalar. Note that tf.summary.scalar uses the node name instead of the tag. This means that TensorFlow will automatically de-duplicate summary names based on the scope they are created in. Also, passing a tensor or list of tags to a scalar summary op is no longer supported.<br>
INFO:tensorflow:Create CheckpointSaverHook.<br>
I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -&gt; (device: 0, name: GeForce GTX 960M, pci bus id: 0000:01:00.0)<br>
INFO:tensorflow:Saving checkpoints for 1 into /tmp/iris_model/model.ckpt.<br>
INFO:tensorflow:loss = 1.21915, step = 1<br>
E tensorflow/stream_executor/cuda/cuda_blas.cc:472] failed to run cuBLAS routine cublasSgemm_v2: CUBLAS_STATUS_EXECUTION_FAILED<br>
W tensorflow/core/framework/op_kernel.cc:993] Internal: Blas SGEMM launch failed : a.shape=(120, 4), b.shape=(4, 10), m=120, n=10, k=4<br>
[[Node: dnn/hiddenlayer_0/MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/gpu:0"](dnn/input_from_feature_columns/input_from_feature_columns/concat, dnn/hiddenlayer_0/weights)]]<br>
W tensorflow/core/framework/op_kernel.cc:993] Internal: Blas SGEMM launch failed : a.shape=(120, 4), b.shape=(4, 10), m=120, n=10, k=4<br>
[[Node: dnn/hiddenlayer_0/MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/gpu:0"](dnn/input_from_feature_columns/input_from_feature_columns/concat, dnn/hiddenlayer_0/weights)]]<br>
Traceback (most recent call last):<br>
File "", line 1, in <br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/util/deprecation.py", line 280, in new_func<br>
return func(*args, **kwargs)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 426, in fit<br>
loss = self._train_model(input_fn=input_fn, hooks=hooks)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 984, in _train_model<br>
_, loss = mon_sess.run([model_fn_ops.train_op, model_fn_ops.loss])<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/monitored_session.py", line 462, in run<br>
run_metadata=run_metadata)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/monitored_session.py", line 786, in run<br>
run_metadata=run_metadata)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/monitored_session.py", line 744, in run<br>
return self._sess.run(*args, **kwargs)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/monitored_session.py", line 891, in run<br>
run_metadata=run_metadata)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/monitored_session.py", line 744, in run<br>
return self._sess.run(*args, **kwargs)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 767, in run<br>
run_metadata_ptr)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 965, in _run<br>
feed_dict_string, options, run_metadata)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1015, in _do_run<br>
target_list, options, run_metadata)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1035, in _do_call<br>
raise type(e)(node_def, op, message)<br>
tensorflow.python.framework.errors_impl.InternalError: Blas SGEMM launch failed : a.shape=(120, 4), b.shape=(4, 10), m=120, n=10, k=4<br>
[[Node: dnn/hiddenlayer_0/MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/gpu:0"](dnn/input_from_feature_columns/input_from_feature_columns/concat, dnn/hiddenlayer_0/weights)]]<br>
[[Node: train_op/dnn/train/update/_198 = _Recv<a href="">client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_175_train_op/dnn/train/update", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"</a>]]</p>
</blockquote>
</blockquote>
</blockquote>
<p dir="auto">Caused by op u'dnn/hiddenlayer_0/MatMul', defined at:<br>
File "", line 1, in <br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/util/deprecation.py", line 280, in new_func<br>
return func(*args, **kwargs)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 426, in fit<br>
loss = self._train_model(input_fn=input_fn, hooks=hooks)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 934, in _train_model<br>
model_fn_ops = self._call_legacy_get_train_ops(features, labels)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 1003, in _call_legacy_get_train_ops<br>
train_ops = self._get_train_ops(features, labels)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 1162, in _get_train_ops<br>
return self._call_model_fn(features, labels, model_fn_lib.ModeKeys.TRAIN)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 1133, in _call_model_fn<br>
model_fn_results = self._model_fn(features, labels, **kwargs)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/dnn.py", line 143, in _dnn_model_fn<br>
scope=scope)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 177, in func_with_args<br>
return func(*args, **current_args)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/layers/python/layers/layers.py", line 1409, in fully_connected<br>
outputs = layer.apply(inputs)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/layers/base.py", line 303, in apply<br>
return self.<strong>call</strong>(inputs, **kwargs)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/layers/base.py", line 273, in <strong>call</strong><br>
outputs = self.call(inputs, **kwargs)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/layers/core.py", line 145, in call<br>
outputs = standard_ops.matmul(inputs, self.kernel)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/math_ops.py", line 1855, in matmul<br>
a, b, transpose_a=transpose_a, transpose_b=transpose_b, name=name)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_math_ops.py", line 1454, in _mat_mul<br>
transpose_b=transpose_b, name=name)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 763, in apply_op<br>
op_def=op_def)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2395, in create_op<br>
original_op=self._default_original_op, op_def=op_def)<br>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1264, in <strong>init</strong><br>
self._traceback = _extract_stack()</p>
<p dir="auto">InternalError (see above for traceback): Blas SGEMM launch failed : a.shape=(120, 4), b.shape=(4, 10), m=120, n=10, k=4<br>
[[Node: dnn/hiddenlayer_0/MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/gpu:0"](dnn/input_from_feature_columns/input_from_feature_columns/concat, dnn/hiddenlayer_0/weights)]]<br>
[[Node: train_op/dnn/train/update/_198 = _Recv<a href="">client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_175_train_op/dnn/train/update", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"</a>]]</p>
<p dir="auto">It seems some APIs are obsolete, can you update some new tf.contrib.learn examples in the website and make it workable with the latest version tensorflow?<br>
And where can I get the new examples for tf.contrib.learn?</p>
<p dir="auto">Thanks!</p>