Opened 8 years ago

Closed 7 years ago

#53946 closed request (fixed)

req: Tensorflow

Reported by: kencu (Ken) Owned by:
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: Schamschula (Marius Schamschula), petrrr, vamsi765
Port:

Description

This seems like a useful tool. I saw this used to good effect in a couple of projects doing image recognition at a major science fair today.

<https://www.tensorflow.org/install/install_sources>

Looks like something for someone skilled in python ports to consider -- and that's not my area.

Change History (16)

comment:1 Changed 8 years ago by kencu (Ken)

argh. this is a port request, not a defect. sorry, can't change it.

comment:2 Changed 8 years ago by Schamschula (Marius Schamschula)

Type: defectrequest

comment:3 Changed 7 years ago by Schamschula (Marius Schamschula)

Cc: Schamschula added

comment:4 Changed 7 years ago by Schamschula (Marius Schamschula)

I've built all the prerequisites for Tensorflow, but I haven't been able to figure out how to get bazel to actually build Tensorflow...

Last edited 7 years ago by Schamschula (Marius Schamschula) (previous) (diff)

comment:5 Changed 7 years ago by kencu (Ken)

Maybe this would be of use?

<https://github.com/Homebrew/homebrew-core/blob/8e76efdb55e8431dff18c470cfd3694db6a9d208/Formula/libtensorflow.rb>

class Libtensorflow < Formula
  desc "C interface for Google's OS library for Machine Intelligence"
  homepage "https://www.tensorflow.org/"
  url "https://github.com/tensorflow/tensorflow/archive/v1.2.0.tar.gz"
  sha256 "03dbf7548d1fc1c11ed58da5fa68616f795c819f868f43478cbcaa26abed374f"

  bottle do
    cellar :any
    sha256 "09c17052b8500ca29b16e0b0cf897ff2f1fa1ac58dbb1f8379620f74727cbe75" => :sierra
    sha256 "5253b9433228b62e9db77e03ad76f2d03960c9e8e5d7c3888c44c9f090b38c4b" => :el_capitan
    sha256 "148f9ee2c1a09e20dbbe126212494e76aa8a699801cd8a1f5838d8d4534f0d4d" => :yosemite
  end

  depends_on "bazel" => :build

  def install
    ENV["PYTHON_BIN_PATH"] = which("python").to_s
    ENV["CC_OPT_FLAGS"] = "-march=native"
    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"] = "0"
    ENV["TF_NEED_VERBS"] = "0"
    system "./configure"

    system "bazel", "build", "--compilation_mode=opt", "--copt=-march=native", "tensorflow:libtensorflow.so"
    lib.install "bazel-bin/tensorflow/libtensorflow.so"
    (include/"tensorflow/c").install "tensorflow/c/c_api.h"
    (lib/"pkgconfig/tensorflow.pc").write <<-EOS.undent
      Name: tensorflow
      Description: Tensorflow library
      Version: #{version}
      Libs: -L#{lib} -ltensorflow
      Cflags: -I#{include}
    EOS
  end

  test do
    (testpath/"test.c").write <<-EOS.undent
      #include <stdio.h>
      #include <tensorflow/c/c_api.h>
      int main() {
        printf("%s", TF_Version());
      }
    EOS
    system ENV.cc, "-L#{lib}", "-ltensorflow", "-o", "test_tf", "test.c"
    assert_equal version, shell_output("./test_tf")
  end
end
Version 0, edited 7 years ago by kencu (Ken) (next)

comment:6 Changed 7 years ago by petrrr

Cc: petrrr added

comment:7 Changed 7 years ago by vamsi765

Is somebody looking at this request?

comment:8 Changed 7 years ago by vamsi765

Cc: vamsi765 added

comment:9 Changed 7 years ago by kencu (Ken)

I have what appears to be a working file to build libtensorflow-devel. I only built it on highsierra -- all other systems are presently untested.

<https://github.com/kencu/myports/tree/master/devel/libtensorflow-devel>

Requires (I think) the new build of bazel to build. I used bazel 0.9.0, which is not in MacPorts yet. <https://github.com/kencu/myports/tree/master/devel/bazel>

The build proceeds apace, but then there is a hellish long pause where nothing seems to happen (like 2 hours on my 8 core MacPro). Then -- it's done. If anyone knows what is going on during this pause, feel free to volunteer some advice.

Assuming this passes criticism, I'll commit it once bazel 0.9.0 is in MacPorts.

Last edited 7 years ago by kencu (Ken) (previous) (diff)

comment:10 Changed 7 years ago by mf2k (Frank Schima)

See #55407 for the bazel update.

comment:11 Changed 7 years ago by vamsi765

Hi,

Now that Bazel 0.9.0 is in, would this also be added to MacPort?

Thanks Vamsi

comment:12 Changed 7 years ago by jmroot (Joshua Root)

Resolution: fixed
Status: newclosed

comment:13 Changed 7 years ago by vamsi765

Hi,

There doesn't seem to be a dependency port.

> sudo port install py36-tensorflow-tensorboard
Password:
--->  Computing dependencies for py36-tensorflow-tensorboard
Error: Dependency 'py36-protobuf3' not found.
Error: Follow https://guide.macports.org/#project.tickets to report a bug.
Error: Processing of port py36-tensorflow-tensorboard failed


> sudo port install py36-tensorflow
--->  Computing dependencies for py36-tensorflow
Error: Dependency 'py36-protobuf3' not found.
Error: Follow https://guide.macports.org/#project.tickets to report a bug.
Error: Processing of port py36-tensorflow failed

> sudo port install py36-protobuf3
Error: Port py36-protobuf3 not found

comment:14 Changed 7 years ago by vamsi765

Resolution: fixed
Status: closedreopened

comment:15 Changed 7 years ago by kencu (Ken)

these issues are being tracked in another ticket 55972

comment:16 Changed 7 years ago by kencu (Ken)

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.