<jupyter_start><jupyter_text>Copyright 2018 The TensorFlow Authors.<jupyter_code>#@title Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.<jupyter_output><empty_output><jupyter_text>Install TensorFlow for C       View on TensorFlow.org        Run in Google Colab        View source on GitHub        Download notebook   TensorFlow provides a C API that can be used to build[bindings for other languages](https://github.com/tensorflow/docs/tree/master/site/en/r1/guide/extend/bindings.md).The API is defined inc_api.hand designed for simplicity and uniformity rather than convenience.  Nightly Libtensorflow C packagesLibtensorflow packages are built nightly and uploaded to GCS for all supportedplatforms. They are uploaded to the[libtensorflow-nightly GCS bucket](https://storage.googleapis.com/libtensorflow-nightly)and are indexed by operating system and date built. For MacOS and Linux sharedobjects, we have a[script](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/tools/ci_build/builds/libtensorflow_nightly_symlink.sh)that renames the .so files versioned to the current date copied into thedirectory with the artifacts.  Supported PlatformsTensorFlow for C is supported on the following systems:* Linux, 64-bit, x86* macOS, Version 10.12.6 (Sierra) or higher* Windows, 64-bit x86  Setup  Download & extract  TensorFlow C libraryURL  Linux      Linux CPU only    https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-2.7.0.tar.gz        Linux GPU support    https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-linux-x86_64-2.7.0.tar.gz    macOS      macOS CPU only    https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-darwin-x86_64-2.7.0.tar.gz    Windows      Windows CPU only    https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-windows-x86_64-2.7.0.zip        Windows GPU only    https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-windows-x86_64-2.7.0.zip   Extract the downloaded archive, which contains the header files to include inyour C program and the shared libraries to link against.On Linux and macOS, you may want to extract to `/usr/local/lib`:<jupyter_code>%%bash
FILENAME=libtensorflow-cpu-linux-x86_64-2.7.0.tar.gz
wget -q --no-check-certificate https://storage.googleapis.com/tensorflow/libtensorflow/${FILENAME}
sudo tar -C /usr/local -xzf ${FILENAME}<jupyter_output><empty_output><jupyter_text>LinkerOn Linux/macOS, if you extract the TensorFlow C library to a system directory,such as `/usr/local`, configure the linker with `ldconfig`:<jupyter_code>%%bash
sudo ldconfig /usr/local/lib<jupyter_output><empty_output><jupyter_text>If you extract the TensorFlow C library to a non-system directory, such as`~/mydir`, then configure the linker environmental variables: Linuxexport LIBRARY_PATH=$LIBRARY_PATH:~/mydir/libexport LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/mydir/libmacOSexport LIBRARY_PATH=$LIBRARY_PATH:~/mydir/libexport DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:~/mydir/lib  Build  Example programWith the TensorFlow C library installed, create an example program with thefollowing source code (`hello_tf.c`):<jupyter_code>%%writefile hello_tf.c
#include <stdio.h>
#include <tensorflow/c/c_api.h>

int main() {
  printf("Hello from TensorFlow C library version %s\n", TF_Version());
  return 0;
}<jupyter_output><empty_output><jupyter_text>CompileCompile the example program to create an executable, then run:<jupyter_code>%%bash
gcc hello_tf.c -ltensorflow -o hello_tf

./hello_tf<jupyter_output><empty_output><jupyter_text>Success: The TensorFlow C library is configured. If the program doesn't build, make sure that `gcc` can access the TensorFlow Clibrary. If extracted to `/usr/local`, explicitly pass the library location tothe compiler:<jupyter_code>%%bash
gcc -I/usr/local/include -L/usr/local/lib hello_tf.c -ltensorflow -o hello_tf

./hello_tf<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09033566118495157, 'fraction_numerical': 0.014642937598558234, 'mean_word_length': 5.183844011142061, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 10, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '391608', 'license': 'Apache-2.0', 'n_tokens_mistral': 1403, 'n_tokens_neox': 1313, 'n_words': 405, 'path': 'site/en/install/lang_c.ipynb', 'repo_name': 'Hayyan-Arshad/docs', 'size': '4439'}