MAC M1芯片配置Python环境Conda安装Tensoflow报错解决方案

苹果官方提供安装conda的解决方案https://developer.apple.com/metal/tensorflow-plugin/
在Mac上使用TensorFlow加速机器学习模型的培训。安装TensorFlow和TensorFlow metal PluggableDevice,在Mac GPU上使用metal加速训练。

操作系统要求:

  • macOS 12.0+ (latest beta)

不支持:

  • Multi-GPU support
  • Acceleration for Intel GPUs
  • V1 TensorFlow Networks

安装conda:

chmod +x ~/Downloads/Miniforge3-MacOSX-arm64.sh
sh ~/Downloads/Miniforge3-MacOSX-arm64.sh #中间会要输入yes两次
source ~/miniforge3/bin/activate
conda create -n tf26 python==3.9
conda activate tf26
  1. 安装TensorFlow在apple的依赖

    conda install -c apple tensorflow-deps
    

    升级:

    # uninstall existing tensorflow-macos and tensorflow-metal
    python -m pip uninstall tensorflow-macos
    python -m pip uninstall tensorflow-metal
    # Upgrade tensorflow-deps
    conda install -c apple tensorflow-deps --force-reinstall
    # or point to specific conda environment
    conda install -c apple tensorflow-deps --force-reinstall -n my_env
    

    安装TensorFlow-deps v2.5

    conda install -c apple tensorflow-deps==2.5.0
    

    安装TensorFlow-deps v2.6

    conda install -c apple tensorflow-deps==2.6.0
    
  2. 安装TensorFlow

    python -m pip install tensorflow-macos
    python -m pip install tensorflow-metal
    

你可能感兴趣的:(AI学习,python,macos,conda)