关于tensorflow:Mac-M1安装tensorflow过程简单网速快的话10分钟搞定

6次阅读

共计 841 个字符,预计需要花费 3 分钟才能阅读完成。

1.macos 版本 12 及以上

2. 装置 arm64 macos 的 miniconda

在此处下载。
选中下图文件中的版本。

# 下载完当前在 terminal 顺次输出以下三个命令
    chmod +x ~/Downloads/Miniforge3-MacOSX-arm64.sh
    sh ~/Downloads/Miniforge3-MacOSX-arm64.sh
    source ~/miniforge3/bin/activate

3. 更换 conda 下载源

因为 conda 国内下载速度慢,更换为国内镜像地址。
在终端中顺次输出以下两行命令。

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

conda config --set show_channel_urls yes

4. 新建 conda 环境

因为我本机的 conda 的 base 环境是 3.9,所以我也应用 3.9 创立虚拟环境
在终端中输出以下命令。

conda create -n tf python==3.9

切换到新环境
在终端中输出以下命令。

conda activate tf

5. 装置 tensorflow

# pip 下载在国内也很慢,很容易网络连接超时,-i https://pypi.tuna.tsinghua.edu.cn/simple 可能切换到清华源下载

# 在终端中顺次输出以下三行命令。这三行命令都是下载包,可能速度有点慢,然而切换源之后应该速度很快。conda install -c apple tensorflow-deps
python -m pip install tensorflow-macos -i https://pypi.tuna.tsinghua.edu.cn/simple
python -m pip install tensorflow-metal -i https://pypi.tuna.tsinghua.edu.cn/simple

6. 参考文献

Mac M1 装置原生 tensorflow(超简略,亲测可用)

正文完
 0