MAC笔记安装Pytorch 环境安装
1. 安装brew
方法1 参考: https://www.jianshu.com/p/e0471aa6672d?utm_campaign=hugo
使用中科大镜像加速访问:
/usr/bin/ruby -e "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install)"
参考: https://zhuanlan.zhihu.com/p/90508170
实测执行如下代码:
(base) MacBook-Pro:resume yinfufeng$ /bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"
设置清华源:
git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git brew update
2. 安装Anaconda
[1] 添加Anaconda的TUNA镜像
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
[2]设置搜索时显示通道地址
conda config --set show_channel_urls yes
[3] 安装anaconda
curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh sh Miniconda3-latest-MacOSX-x86_64.sh
##3. 安装pytortch
1)设置Python版本为3.9版本,创建pytorch环境
(base) MacBook-Pro:DeepLab fyf$ conda create -n pytorch_py39_env python=3.9
2)安装pytorch包
参考 https://pytorch.org/get-started/locally/
- [1] 激活环境
(base) MacBook-Pro:DeepLab fyf$ conda activate pytorch_py39_env (pytorch_py39_env) MacBook-Pro:DeepLab yinfufeng$
- [2]安装依赖数据包
conda install pytorch torchvision torchaudio -c pytorch
- [3] 退出环境:
$ conda deactivate
- notebook
安装jupyter notebook后,执行命令:
jupyter notebook
参考资料
[1] Anaconda documentation
https://docs.anaconda.com/anaconda/user-guide/tasks/tensorflow/