Apple Silicon MacBook Pro新机配置

本文最后更新于:2022年7月31日 下午

本文记录下由intel转移到m1的过程中重装各种环境和工具的命令和配置

配置git

mac自带git,所以只需要配置下用户名和邮箱

1
2
git config --global user.name "John Doe"
git config --global user.email "johndoe@example.com"

安装brew

Homebrew

1
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

根据返回的最后内容执行提示的代码,将brew添加到path中

1
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/ashone/.zprofile

最后在终端中输入brew测试是否添加成功

安装iTerm2

iTerm2 - macOS Terminal Replacement

安装oh-my-zsh

Oh My Zsh - a delightful & open source framework for Zsh

1
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

安装zsh主题

我选择安装powerlevel10k主题,链接在这里https://github.com/romkatv/powerlevel10k

  1. 安装字体(可跳过)

    MesloLGS NF Regular.ttf

    MesloLGS NF Bold.ttf

    MesloLGS NF Italic.ttf

    MesloLGS NF Bold Italic.ttf

  2. 手动安装主题文件

    1
    git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

  3. 编辑配置文件,修改主题为10k

    1
    code ~/.zshrc

    也可以使用其他编辑器打开这个文件

    然后找到第11行修改主题为

    1
    powerlevel10k/powerlevel10k

  4. 重启iterm,加载主题文件

  5. 依次根据样式进行配置

  6. 重启iterm就可以看到崭新的主题了

安装oh-my-zsh自动补全插件

GitHub - zsh-users/zsh-autosuggestions: Fish-like autosuggestions for zsh

  1. 下载插件

    1
    git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

  2. 编辑zshrc配置文件,增加插件,修改配色

    1
    code ~/.zshrc

    1
    2
    3
    4
    5
    6
    plugins=( 
    # other plugins...
    zsh-autosuggestions
    )
    # 此处修改autosuggestions插件的配色
    ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#d0d0d0,underline"

  3. 重开iterm

查看效果:

配置python和conda

Miniconda - Conda documentation

安装miniconda对应版本的pkg,双击后直接安装,在终端测试conda命令是否正常

查看conda环境, 创建新python环境

1
2
3
4
5
conda env list
conda create -n your_env_name python=x.x

conda activate dl
conda deactivate

安装pytorch(Apple Silicon版本)

PyTorch

pytorch从1.13版本开始支持苹果芯片gpu加速,目前(7.30)还得安装nightly版本

1
conda install pytorch -c pytorch-nightly

用python测试查看版本号,torch版本为1.13开发版就代表安装成功

1
2
3
4
5
6
7
❯ python
Python 3.8.13 (default, Mar 28 2022, 06:13:39)
[Clang 12.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.__version__
'1.13.0.dev20220729'

Apple Silicon MacBook Pro新机配置
https://ash-one.github.io/2022/07/31/apple-silicon-macbook-pro-xin-ji-pei-zhi/
作者
灰一
发布于
2022年7月31日
许可协议