安装基本工具
bash
pacman -S --needed zip unzip patch diffutils git
下载安装 Windows 版本 bazel 6.1.2,复制到 C:/Windows/system32 目录下,改名为 bazel.exe
bash
wget https://github.com/bazelbuild/bazel/releases/download/6.1.2/bazel-6.1.2-windows-x86_64.exe
## 国内镜像
wget https://hub.nuaa.cf/bazelbuild/bazel/releases/download/6.1.2/bazel-6.1.2-windows-x86_64.exe
下载 tensorflow :
bash
git clone --recursive https://github.com/tensorflow/tensorflow.git
cd tensorflow
# switch to the branch you want to build
git checkout r2.14 # r1.9, r1.10, etc.
或下载源码包并解压
bash
wget https://hub.nuaa.cf/tensorflow/tensorflow/archive/refs/tags/v2.14.0.tar.gz
tar xf v2.14.0.tar.gz
换国内github 镜像,加速下载
bash
sed -i -e 's#https:\/\/github\.com#https://hub.yzuu.cf#g' */*.bzl */*/*.bzl
sed -i -e 's#https:\/\/storage\.googleapis\.com\/mirror\.tensorflow\.org\/github\.com#https://hub.yzuu.cf#g' */*.bzl */*/*.bzl
编译 & 安装:
bash
./configure
## tensorflow:libtensorflow_cc.so
bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package
## build install python-package
bazel-bin/tensorflow/tools/pip_package/build_pip_package package/20230912
## remove old version and install new package
pip uninstall tensorflow
pip install package/20230912/tensorflow-*.whl