1.创建环境
conda create --name pytorch python=3.11.5
2.激活环境
source activate pytorch
3.添加国内镜像源:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes
4.配置pytorch CPU版本
CPU版本:
pip install torch torchvision torchaudio -i https://pypi.tuna.tsinghua.edu.cn/simple
GPU版本:cuda11.8版本
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 -i https://pypi.tuna.tsinghua.edu.cn/simple