Last active
February 18, 2020 22:04
-
-
Save m4ce/5fc537fac0b02c2e0257b84cded68fe1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Tensorflow < Formula | |
include Language::Python::Virtualenv | |
desc "Computation using data flow graphs for scalable machine learning" | |
homepage "https://www.tensorflow.org/" | |
url "https://github.com/tensorflow/tensorflow/archive/v2.1.0.tar.gz" | |
sha256 "638e541a4981f52c69da4a311815f1e7989bf1d67a41d204511966e1daed14f7" | |
revision 8 | |
depends_on "bazel" => :build | |
depends_on "python" => "3.7" | |
def install | |
# Bazel fails if version from .bazelversion doesn't match bazel version, so just to use the latest one | |
rm_f ".bazelversion" | |
venv = virtualenv_create("#{buildpath}/venv", "python3") | |
venv.pip_install "numpy==1.18.1" | |
venv.pip_install "six==1.14.0" | |
ENV["PYTHON_BIN_PATH"] = "#{buildpath}/venv/bin/python" | |
ENV["CC_OPT_FLAGS"] = "-march=native" | |
ENV["TF_IGNORE_MAX_BAZEL_VERSION"] = "1" | |
ENV["TF_NEED_JEMALLOC"] = "1" | |
ENV["TF_NEED_GCP"] = "0" | |
ENV["TF_NEED_HDFS"] = "0" | |
ENV["TF_ENABLE_XLA"] = "0" | |
ENV["USE_DEFAULT_PYTHON_LIB_PATH"] = "1" | |
ENV["TF_NEED_OPENCL"] = "0" | |
ENV["TF_NEED_CUDA"] = "0" | |
ENV["TF_NEED_MKL"] = "1" | |
ENV["TF_NEED_VERBS"] = "0" | |
ENV["TF_NEED_MPI"] = "0" | |
ENV["TF_NEED_S3"] = "0" | |
ENV["TF_NEED_GDR"] = "0" | |
ENV["TF_NEED_KAFKA"] = "0" | |
ENV["TF_NEED_OPENCL_SYCL"] = "0" | |
ENV["TF_NEED_ROCM"] = "0" | |
ENV["TF_DOWNLOAD_CLANG"] = "0" | |
ENV["TF_SET_ANDROID_WORKSPACE"] = "0" | |
ENV["TF_CONFIGURE_IOS"] = "0" | |
system "./configure" | |
bazel_args =%W[ | |
--config=opt | |
--config=mkl | |
--copt=-march=native | |
--compilation_mode=opt | |
--config=nogcp | |
--config=nohdfs | |
--config=nonccl | |
--local_cpu_resources=HOST_CPUS-1 | |
--local_ram_resources=HOST_RAM*.5 | |
] | |
targets = %w[ | |
tensorflow:libtensorflow.so | |
tensorflow/tools/benchmark:benchmark_model | |
tensorflow/tools/graph_transforms:summarize_graph | |
tensorflow/tools/graph_transforms:transform_graph | |
] | |
system "bazel", "build", *bazel_args, *targets | |
lib.install Dir["bazel-bin/tensorflow/*.so*", "bazel-bin/tensorflow/*.dylib*"] | |
(include/"tensorflow").install %w[ | |
tensorflow/core | |
tensorflow/c | |
tensorflow/cc | |
] | |
bin.install %w[ | |
bazel-bin/tensorflow/tools/benchmark/benchmark_model | |
bazel-bin/tensorflow/tools/graph_transforms/summarize_graph | |
bazel-bin/tensorflow/tools/graph_transforms/transform_graph | |
] | |
(lib/"pkgconfig/tensorflow.pc").write <<~EOS | |
Name: tensorflow | |
Description: Tensorflow library | |
Version: #{version} | |
Libs: -L#{lib} -ltensorflow | |
Cflags: -I#{include} | |
EOS | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment