本文主要是介绍Windows + Msys 下编译 TensorFlow 2.14,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
安装基本工具
pacman -S --needed zip unzip patch diffutils git
下载安装 Windows 版本 bazel 6.1.2,复制到 C:/Windows/system32 目录下,改名为 bazel.exe
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 :
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.
或下载源码包并解压
wget https://hub.nuaa.cf/tensorflow/tensorflow/archive/refs/tags/v2.14.0.tar.gz
tar xf v2.14.0.tar.gz
换国内github 镜像,加速下载
sed -i -e 's#https:\/\/github\.com#https://hub.yzuu.cf#g' */*.bzl */*/*.bzl
编译 & 安装:
./configure
## tensorflow:libtensorflow_cc.so
bazel build --config=opt //tensorflow:libtensorflow_cc.so## tensorflow:libtensorflow_cc.so with cuda
bazel build --config=opt --config=cuda //tensorflow:libtensorflow_cc.so## tensorflow/tools/pip_package:build_pip_package
bazel build -c opt --copt=-msse3 --copt=-msse4.1 --copt=-msse4.2 --copt=-mavx --copt=-mavx2 --copt=-mfma //tensorflow:libtensorflow_cc.so## 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
这篇关于Windows + Msys 下编译 TensorFlow 2.14的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!