欢迎您访问365答案网,请分享给你的朋友!
生活常识 学习资料

MacM1安装TensorFlow

时间:2023-08-26

1.下载Xcode

2.安装Miniforge
点击这里
链接:https://github.com/conda-forge/miniforge

下载到本地,执行

bash Miniforge3-MacOSX-arm64.sh

基本都是回车操作,中间输入一次yes,就安装好了

3.确认Miniforge安装成功

4.创建conda环境
执行:

conda create --name python38 python=3.8

可以通过下面命令确认已经创建好conda环境。

conda env list

激活环境:

conda activate python38

注:如果激活环境出现问题,可以尝试执行下面语句

#重新进入虚拟环境source activate#退出虚拟环境conda deactivate

再重新执行激活环境的命令即可解决

5.下载tensorflow
下载地址:https://github.com/apple/tensorflow_macos/releases,选择tar.gz的包下载。
解压:

tar -xvf tensorflow_macos-0.1alpha3.tar.gz

6.安装依赖

download_path="~/Downloads/tensorflow_macos/arm64/"target_path="~/miniforge3/env/python38/"# 安装相关依赖pip install --upgrade -t "$target_path/lib/python3.8/site-packages/" --no-dependencies --force "$download_path/grpcio-1.33.2-cp38-cp38-macosx_11_0_arm64.whl" pip install --upgrade -t "$target_path/lib/python3.8/site-packages/" --no-dependencies --force "$download_path/h5py-2.10.0-cp38-cp38-macosx_11_0_arm64.whl" pip install --upgrade -t "$target_path/lib/python3.8/site-packages/" --no-dependencies --force "$download_path/tensorflow_addons_macos-0.1a2-cp38-cp38-macosx_11_0_arm64.whl" pip install --upgrade -t "$target_path/lib/python3.8/site-packages/" --no-dependencies --force "$download_path/numpy-1.18.5-cp38-cp38-macosx_11_0_arm64.whl"

中间可能会提示需要安装的库:

# 安装相关库conda install -c conda-forge -y absl-pyconda install -c conda-forge -y wheelconda install -c conda-forge -y typing_extensionsconda install -c conda-forge -y gastconda install -c conda-forge -y opt_einsumconda install -c conda-forge -y termcolorconda install -c conda-forge -y typeguard

安装tensorflow

pip install --upgrade -t "$target_path/lib/python3.8/site-packages/" --no-dependencies --force “$download_path/tensorflow_macos-0.1a3-cp38-cp38-macosx_11_0_arm64.whl"

Copyright © 2016-2020 www.365daan.com All Rights Reserved. 365答案网 版权所有 备案号:

部分内容来自互联网,版权归原作者所有,如有冒犯请联系我们,我们将在三个工作时内妥善处理。