本文详细介绍了如何通过命令和源码安装 PyTorch,并演示了在源码编译时如何使用自定义的 NCCL 动态库和静态库。以下是完整的步骤和说明
假定已经安装了GPU驱动和cuda。
安装anaconda
Anaconda 是一个 Python 虚拟环境管理工具,可以方便地管理多个 Python 环境。
下载anaconda
在官网下载 Anaconda3-2024.10-1-Linux-x86_64.sh,并执行安装anaconda
更改anaconda国内源
配置文件~/.condarc
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/conda-forge/
conda config --set show_channel_urls yes
更改pip国内源
配置文件~/.pip/pip.conf
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple/
[install]
trusted-host=https://pypi.tuna.tsinghua.edu.cn
更新
conda update conda -y
conda update anaconda -y
conda update python -y
conda update --all -y
安装好anoconda后,系统界面如下
默认有一个base虚拟环境,可在此环境执行,也可创建新的虚拟环境
(base) ~# conda env list
# conda environments:
#
base * /root/anaconda3
使用命令安装pytorch
创建虚拟环境,名字为pytorch
conda creat