{"id":101,"date":"2023-07-29T19:16:00","date_gmt":"2023-07-30T00:16:00","guid":{"rendered":"https:\/\/overthinking.tech\/?p=101"},"modified":"2025-02-12T19:20:53","modified_gmt":"2025-02-13T01:20:53","slug":"compile-tensorflow-from-source-rebuild-tensorflow-with-compiler-flags-a-tutorial","status":"publish","type":"post","link":"https:\/\/overthinking.tech\/?p=101","title":{"rendered":"Compile TensorFlow from Source, rebuild TensorFlow with compiler flags, a tutorial"},"content":{"rendered":"\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Compile TensorFlow from Source, rebuild TensorFlow with compiler flags, a tutorial\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/S-DM9GsKUv0?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">In this video I&#8217;m showing how to compile TensorFlow from source. This resolves the warning &#8220;rebuild TensorFlow with the appropriate compiler flags&#8221; I also discuss CPU instructions and how they can make our computers faster. Finally I compare speed to see if it is &#8220;worth&#8221; compiling from source. <br>TensorFlow&#8217;s Instructions: <a href=\"https:\/\/www.youtube.com\/redirect?event=video_description&amp;redir_token=QUFFLUhqbDVOMFBvWE9PcmFJWHQxWVlld2ktd2htOUgzd3xBQ3Jtc0trRVYtT1NIZ1FwU0FfTXQzQ0FGbFhIR0JsdXBaT21oWjcyaDh3VjItcjNXWlFmaXdqc2d5NzUzamJUcG9KQjNZTGhNeVB4RWtQOUNyNmpscU1LZkUxLW90ak4xVHZTaTdHdkQwU3l2d205MkFuMldoZw&amp;q=https%3A%2F%2Fwww.tensorflow.org%2Finstall%2Fsource&amp;v=S-DM9GsKUv0\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.tensorflow.org\/install\/so&#8230;<\/a> Here are all the commands, copy pasta to your hearts content:<br>curl <a href=\"https:\/\/repo.anaconda.com\/miniconda\/Miniconda3-latest-Linux-x86_64.sh\">https:\/\/repo.anaconda.com\/miniconda\/Miniconda3-latest-Linux-x86_64.sh<\/a> -o Miniconda3-latest-Linux-x86_64.sh<br>bash Miniconda3-latest-Linux-x86_64.sh<br>conda create &#8211;name pythontemp python=3.10<br>conda activate pythontemp<br>pip install -U &#8211;user pip numpy wheel packaging requests opt_einsum<br>pip install -U &#8211;user keras_preprocessing &#8211;no-deps<br>sudo apt install gcc g++ patchelf<br>git clone <a href=\"https:\/\/github.com\/tensorflow\/tensorflow\">https:\/\/github.com\/tensorflow\/tensorflow<\/a><br>cd tensorflow<br>python3 configure.py<br>cd ..<br>sudo mv bazelisk-linux-amd64 \/usr\/local\/bin\/bazel<br>sudo chmod +x \/usr\/local\/bin\/bazel<br>cd tensorflow<br>sudo bazel build -j 12 &#8211;local_ram_resources=8192 &#8211;config=opt \/\/tensorflow\/tools\/pip_package:build_pip_package<br>sudo .\/bazel-bin\/tensorflow\/tools\/pip_package\/build_pip_package \/tmp\/tensorflow_pkg<br>pip install \/tmp\/tensorflow_pkg\/tensorflow-&#8230;.whl<br>ln -sf \/usr\/lib\/x86_64-linux-gnu\/libstdc++.so.6 \/home\/jtrev\/miniconda3\/envs\/pythontemp\/bin\/..\/lib\/libstdc++.so.6<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this video I&#8217;m showing how to compile TensorFlow from source. This resolves the warning &#8220;rebuild TensorFlow with the appropriate compiler flags&#8221; I also discuss CPU instructions and how they<\/p>\n<p><a href=\"https:\/\/overthinking.tech\/?p=101\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\">Compile TensorFlow from Source, rebuild TensorFlow with compiler flags, a tutorial<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":102,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-101","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-youtube"],"_links":{"self":[{"href":"https:\/\/overthinking.tech\/index.php?rest_route=\/wp\/v2\/posts\/101","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/overthinking.tech\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/overthinking.tech\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/overthinking.tech\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/overthinking.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=101"}],"version-history":[{"count":1,"href":"https:\/\/overthinking.tech\/index.php?rest_route=\/wp\/v2\/posts\/101\/revisions"}],"predecessor-version":[{"id":103,"href":"https:\/\/overthinking.tech\/index.php?rest_route=\/wp\/v2\/posts\/101\/revisions\/103"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/overthinking.tech\/index.php?rest_route=\/wp\/v2\/media\/102"}],"wp:attachment":[{"href":"https:\/\/overthinking.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=101"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/overthinking.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=101"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/overthinking.tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}