tensoflow 编译

https://www.tensorflow.org/install/source
https://blog.csdn.net/u011285477/article/details/93975689

https://blog.csdn.net/u012614287/article/details/90415545
./configure  # answer prompts or use defaults

bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package

./bazel-bin/tensorflow/tools/pip_package/build_pip_package /mnt  # create package

chown $HOST_PERMS /mnt/tensorflow-version-tags.whl
pip uninstall tensorflow  # remove current version

pip install /mnt/tensorflow-version-tags.whl
cd /tmp  # don't import from source directory
python -c "import tensorflow as tf; print(tf.__version__)"
bazel build --config=opt //tensorflow:libtensorflow_cc.so

  

 
sudo docker run -it  --name=tongxiao_tensorflow --net=host  -w /tensorflow -v /mnt/sdi/tongxiao.wzb/tensorflow:/tensorflow -v $PWD:/mnt -e HOST_PERMS="$(id -u):$(id -g)" tensorflow/tensorflow:devel bash
g++ -o test test.cc --std=c++11 -I../eigen/eigen-master -I../../tensorflow/tensorflow/third_party -I../../tensorflow/tensorflow -L./lib -ltensorflow_cc -ltensorflow_framework -I/usr/local/lib/python3.6/dist-packages/tensorflow/include/

https://gitlab.com/libeigen/eigen

  

 

#include "tensorflow/cc/client/client_session.h"
#include "tensorflow/cc/ops/standard_ops.h"
#include "tensorflow/core/framework/tensor.h"

int main() {
  using namespace tensorflow;
  using namespace tensorflow::ops;
  Scope root = Scope::NewRootScope();
  // Matrix A = [3 2; -1 0]
  auto A = Const(root, { {3.f, 2.f}, {-1.f, 0.f}});
  // Vector b = [3 5]
  auto b = Const(root, { {3.f, 5.f}});
  // v = Ab^T
  auto v = MatMul(root.WithOpName("v"), A, b, MatMul::TransposeB(true));
  std::vector<Tensor> outputs;
  ClientSession session(root);
  // Run and fetch v
  TF_CHECK_OK(session.Run({v}, &outputs));
  // Expect outputs[0] == [19; -3]
  std::cout<< outputs[0].matrix<float>();
  return 0;
}

 

posted @ 2021-04-26 15:10  通杀  阅读(67)  评论(0编辑  收藏  举报