本文是Mac m1的深度環(huán)境安裝指南。一方面,記錄了一些有用的鏈接,這些鏈接講述了m1芯片與Intel芯片的不同之處以及在安裝mac m1時(shí)需要注意的問(wèn)題。另一方面,記錄了我安裝時(shí)的全過(guò)程,安裝內(nèi)容包括vscode, pytorch, jupyter。
m1芯片不同在哪?
https://www.anaconda.com/blog/apple-silicon-transition
從下面得知,對(duì)于m1芯片,下載安裝包時(shí)應(yīng)該注意下載注明有AArch64,ARM Macs,ARM64,ARMv8,osx-arm64的包。
Intel CPUs support the x86-64 ISA (sometimes also called AMD64 because AMD originally proposed this 64-bit extension to x86 back in 1999). The new Apple Silicon CPUs use an ISA designed by ARM called AArch64, just like the iPhone and iPad CPUs they descend from. For this reason, these new Macs are often called “ARM Macs” in contrast to “Intel Macs,” although ARM only defined the ISA used by the Apple M1 but did not design the CPU. In general, the naming conventions for 64-bit ARM architectures are confusing, as different people will use subtly different terms for the same thing. You may see some people call these “ARM64” CPUs (which is what Apple does in their developer tools), or slightly incorrectly as “ARMv8” (which is a specification that describes both AArch64 and AArch32). Even in conda, you’ll see the platform names osx-arm64, which you would use for macOS running on the M1, and linux-aarch64, which you would use for Linux running on a 64-bit ARM CPU.
配置環(huán)境前的注意:
m1芯片的mac做深度學(xué)習(xí)? - 真中合歡的回答 - 知乎
https://www.zhihu.com/question/493225739/answer/2178223987
1.下載vs code
vs code下載地址:https://code.visualstudio.com/Download#
- 現(xiàn)在(2022-01-17 19:08:13)已經(jīng)支持mac m1,不用通過(guò) Rosetta 仿真來(lái)運(yùn)行了。
- 下載時(shí)選擇universal版本或者apple silicon。
- 如果下載速度過(guò)慢,可以使用鏡像下載,可以參考以下鏈接。
https://blog.csdn.net/weixin_44041875/article/details/120039029
2. 安裝pytorch與jupyter
M1 mac安裝PyTorch的完整步驟指南 - deephub的文章 - 知乎
https://zhuanlan.zhihu.com/p/394514049
- 安裝homebrew
/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)”
安裝后如果報(bào)錯(cuò):
Warning: /opt/homebrew/bin is not in your PATH.
按照指引添加路徑。
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/<用戶(hù)名>/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
- 安裝mini forge
- 安裝mini forge
brew install miniforge - 為Z shell (zsh)初始化conda
conda init zsh
- 安裝pytorch
創(chuàng)建虛擬環(huán)境,并在環(huán)境中安裝pytorch
- 安裝環(huán)境基于pytorch3.8,名為torchenv的環(huán)境
conda create --name torchenv python=3.8
conda init zsh #為Z shell (zsh)初始化conda - 在環(huán)境中安裝pytorch
conda activate torchenv #激活環(huán)境
conda install -c pytorch pytorch #安裝pytorch
- 安裝jupyter
在安裝的環(huán)境下,安裝jupyter notebook
conda install jupyter notebook - 將環(huán)境與vs code的interpreter鏈接
首先找到環(huán)境的路徑:
conda env list
添加該環(huán)境路徑中的,bin中的,python3文件到vs code中。 - 驗(yàn)證安裝
跑一個(gè)程序,打開(kāi)Activity Monitor。
如果你在“Kind”下看到“Apple”,這意味著程序是在M1芯片上本地運(yùn)行的,而不是在Rosetta模擬器下。
2022-01-17 19:08:13 完成