大模型环境配置
·
PyTorch安装
torch1.11.0 - CUDA11.3
pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0 --extra-index-url https://download.pytorch.org/whl/cu113
conda环境移植
# 步骤1:导出环境配置
conda env export -n 原环境名称 > environment.yml
# 步骤2:修改环境名称
sed -i 's/name: 原环境名称/name: 新环境名称/g' environment.yml
# 步骤3:创建新环境
conda env create -f environment.yml
# 示例流程:
conda env export -n pytorch_env > pytorch.yml
sed -i 's/name: pytorch_env/name: pytorch_v2/g' pytorch.yml
conda env create -f pytorch.yml
numpy/scipy/scikit-learn/opencv-python兼容版本
pip install numpy==1.21.6 scipy==1.7.3 scikit-learn==1.0.2 opencv-python==4.6.0.66
conda换源
检查并优化 .condarc 配置
有时候清华源没生效是因为 defaults 通道(官方源)依然排在最前面。请运行 conda config --show-channels 查看,或者直接修改配置文件。
建议的配置: 打开终端,执行 conda config --set show_channel_urls yes,然后编辑 ~/.condarc(Windows 在 C:\Users\用户名.condarc),确保内容如下:
channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
注意: 很多时候慢是因为你在 conda install 时加了 -c pytorch 这样的参数。这会强制 Conda 去官网下载。既然配置了镜像,安装时不要加 -c 参数。
换装“加速引擎”:Libmamba Solver
Conda 官方原生的解析器在处理依赖关系时非常慢。现在官方已经支持了更快的 libmamba 解析器,这能让“Solving environment”的时间从几分钟缩短到几秒钟。
在终端运行以下命令:
# 更新 conda 到最新版
conda update -n base conda
# 安装 libmamba 插件
conda install -n base conda-libmamba-solver
# 设置为默认解析器
conda config --set solver libmamba
pip换源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
mmcv安装
版本关系网址:Installation — mmcv 2.2.0 文档
离线安装包下载网址:download.openmmlab.com/mmcv/dist/cu111/torch1.9.0/index.html
下载后使用pip install your_download_package进行安装
mmcv-full安装直接使用下述代码,修改{mmcv_version}为自己需要的版本:
pip install mmcv-full=={mmcv_version} -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.11.0/index.html
更多推荐


所有评论(0)