Msys下编译 TensorFlow

安装基本工具

pacman -S --needed  zip unzip patch diffutils git

下载安装 Windows 版本 bazel 6.1.2,复制到 C:/Windows/system32 目录下

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 # no NVidia display card
bazel build --config=opt

## tensorflow:libtensorflow_cc.so
bazel build --config=opt --config=cuda

## 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
 
bazel build

## 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

你可能感兴趣的:(tensorflow,人工智能,python)