下载源码
git clone https://github.com/tensorflow/tensorflow
安装bazel 5.1.1
curl -fLO https://releases.bazel.build/5.1.1/release/bazel-5.1.1-linux-x86_64
chmod +x bazel-5.1.1-linux-x86_64
需要jdk1.8安装。?bazel安装。此处理略过
编译
pip3 install numpy
./configure
bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package
#支持cuda的编译命令
bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
安装
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
pip install /tmp/tensorflow_pkg/tensorflow-2.10.0-cp310-cp310-linux_x86_64.whl
验证
python
Python 3.10.0 (default, Nov 10 2021, 19:16:14) [GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> tf.__version__
'2.10.0'
>>>
|