其他分享
首页 > 其他分享> > MacOS下使用conda安装TensorFlow(亲测成功)

MacOS下使用conda安装TensorFlow(亲测成功)

作者:互联网

以下内容参考:

  1. Mac m1芯片anaconda上安装tensorflow 使用资源和安装miniforge
  2. 这次真的搞定了在Mac M1上安装tensorflow,踩坑踩的我脚都断了 参考安装依赖包和tensorflow

一、下载tensorflow文件资源

参考1
二、安装TensorFlow

注:文章里的要在python=3.8时使用
/Users/dulei/Desktop/software/tensorflow_miniconda_macos_package下

/bin/bash ./Miniforge3-MacOSX-arm64.sh

miniforge3安装位置

/Users/dulei/miniforge3

创建虚拟环境

conda create -n tensorflow_env2 python=3.8

激活虚拟环境

conda activate tensorflow_env2

此目录下,/Users/dulei/Desktop/software/tensorflow_miniconda_macos_package/tensorflow_macos/arm64
并激活环境

libs="/Users/dulei/Desktop/software/tensorflow_miniconda_macos_package/tensorflow_macos/arm64/"
env="/Users/dulei/miniforge3/envs/tensorflow_env1"


pip install --upgrade --no-dependencies --force numpy-1.18.5-cp38-cp38-macosx_11_0_arm64.whl grpcio-1.33.2-cp38-cp38-macosx_11_0_arm64.whl h5py-2.10.0-cp38-cp38-macosx_11_0_arm64.whl

pip install absl-py astunparse flatbuffers gast google_pasta keras_preprocessing opt_einsum protobuf tensorflow_estimator termcolor typing_extensions wrapt wheel tensorboard typeguard

pip install --upgrade --force --no-dependencies tensorflow_addons-0.11.2+mlcompute-cp38-cp38-macosx_11_0_arm64.whl

pip install --upgrade --force --no-dependencies tensorflow_macos-0.1a0-cp38-cp38-macosx_11_0_arm64.whl

**三、测试**

- 激活环境

```bash
conda activate tensorflow_env2
  1. 执行下面代码
import tensorflow as tf
print(tf.__version__)
(base) dulei@duleideMacBook-Pro 代码 % conda activate tensorflow_env2
(tensorflow_env2) dulei@duleideMacBook-Pro 代码 % python tensorflow_test.py 
2.4.0-rc0

输出版本号
2.

(tensorflow_env2) dulei@duleideMacBook-Pro arm64 % python
Python 3.8.11 (default, Aug 16 2021, 12:04:33) 
[Clang 12.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
>>>> 

没有错误提示

标签:MacOS,cp38,--,env2,conda,arm64,tensorflow,TensorFlow,dulei
来源: https://blog.csdn.net/qq_42771487/article/details/123585458