第一步 M1芯片安裝Pytorch環(huán)境
安裝Miniforge
Mac打開終端(Mac電腦如何啟動(dòng)終端?打開啟動(dòng)臺(tái),搜索終端即可)
安裝包管理工具Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
如果遇到報(bào)錯(cuò)
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
則需要運(yùn)行一下如下指令,然后再安裝Homebrew。原因是被墻,需要配置一下端口。
export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:789
安裝Homebrew成功后,重啟終端(Mac電腦如何啟動(dòng)終端?打開啟動(dòng)臺(tái),搜索終端即可)直接安裝miniforge。
brew install miniforge
安裝完成之后,為終端初始化conda:
conda init zsh
創(chuàng)建虛擬環(huán)境
使用python 3.8創(chuàng)建名為pytorch_env的虛擬環(huán)境
conda create --name pytorch_env python=3.8
激活虛擬環(huán)境
conda activate pytorch_env
激活成功后,會(huì)看到如下的界面
安裝Pytorch
使用conda命令來安裝pytorch和torchvision
conda install -c pytorch pytorch torchvision
第二步 下載李沐Jupyter文件
進(jìn)入課程主頁:https://courses.d2l.ai/zh-v2/
點(diǎn)擊右上角的Jupyter記事本,即可下載。
第三步 配置vscode
搜索vscode,進(jìn)入vscode官網(wǎng):https://code.visualstudio.com/
下載安裝mac版本的vscode
配置vscode:按Command + Shift + P進(jìn)入搜索欄,輸入python解釋器,選擇之前創(chuàng)建的虛擬環(huán)境:pytorch_env,如下圖所示
如果是新下載的vscode,則需要手動(dòng)打開下面的面板
在下方面板中激活虛擬環(huán)境
conda activate pytorch_env
然后使用conda安裝李沐專用d2l包
conda install d2l
如下圖所示
接著隨便打開一個(gè)下載好的jupyter文件,運(yùn)行即可
文章來源:http://www.zghlxwxcb.cn/news/detail-742228.html
參考
【1】https://zhuanlan.zhihu.com/p/394514049文章來源地址http://www.zghlxwxcb.cn/news/detail-742228.html
到了這里,關(guān)于Mac電腦配置李沐深度學(xué)習(xí)環(huán)境[pytorch版本]使用vscode的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!