北京大興網(wǎng)站建設(shè)公司咨詢產(chǎn)品關(guān)鍵詞
0. 需求說(shuō)明
自用筆記本構(gòu)建一套開發(fā)環(huán)境,用docker 虛擬插件 dev containers,實(shí)現(xiàn)開發(fā)環(huán)境的構(gòu)建,我想構(gòu)建一套LLMs的環(huán)境,由于環(huán)境配置太多,不想污染本地環(huán)境,所以選擇隔離技術(shù)
1. 環(huán)境準(zhǔn)備
- vscode
- docker
2. 步驟
2.1 vscode 安裝插件
- Dev Containers
- Remote Development
2.2 項(xiàng)目根目錄下創(chuàng)建.devcontainer文件
目錄結(jié)構(gòu)
2.2.1 直接用鏡像構(gòu)建環(huán)境
devcontainers.json
VS Code Dev Containers官方文檔
字段說(shuō)明【具體字段參見官方網(wǎng)站字段描述】:
1.name:dev container 名稱
2.image:鏡像名稱
3. customizations:在支持的工具中定義
4. build:dockerfile 構(gòu)建時(shí)需要配置
5. context:構(gòu)建的位置上下文,默認(rèn).
當(dāng)前目錄,..
表示上級(jí)目錄
6. dockerfile: dockerfile 文件
{"name": "LLMs From Scratch","image": "llms-from-scratch:0.1","customizations": {"vscode": {"extensions": ["ms-python.python","ms-azuretools.vscode-docker","ms-toolsai.jupyter","yahyabatulu.vscode-markdown-alert","tomoki1207.pdf","mechatroner.rainbow-csv"]}}
}
2.2.2 用Dockefile構(gòu)建鏡像
devcontainers.json
{"name": "LLMs From Scratch","build": {"context": "..","dockerfile": "Dockerfile"},"customizations": {"vscode": {"extensions": ["ms-python.python","ms-azuretools.vscode-docker","ms-toolsai.jupyter","yahyabatulu.vscode-markdown-alert","tomoki1207.pdf","mechatroner.rainbow-csv"]}}
}
Dockerfile
FROM pytorch/pytorch:2.0.1-cuda11.7-cudnn8-runtimeRUN apt-get update && \apt-get upgrade -y && \apt-get install -y rsync && \apt-get install -y git && \apt-get install -y curl && \rm -rf /var/lib/apt/lists/*COPY requirements.txt requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
requirements 環(huán)境需要的配置信息
torch >= 2.0.1
jupyterlab >= 4.0
tiktoken >= 0.5.1
matplotlib >= 3.7.1
tensorflow >= 2.15.0
tqdm >= 4.66.1
numpy >= 1.25, < 2.0
pandas >= 2.2.1
psutil >= 5.9.5
3.啟動(dòng)環(huán)境
Command + Shift + P
輸入:Dev Containers: Rebuild and Reopen in Container
啟動(dòng)成功截圖
4. 關(guān)閉環(huán)境
File —>close remote connection