一、PyTorch源码编译安装
1、下载pytorch源码
git clone --recursive https://github.com/pytorch/pytorch
cd pytorch
# if you are updating an existing checkout
git submodule sync
git submodule update --init --recursive
注意:在window的git bash中下载的源码拷贝到Linux中会出错。可以在wsl的linux系统中git clone相应源码。
2、创建conda虚拟环境
conda create -n torch_cuda python=3.10
3、安装依赖包
conda install cmake ninja
进入pytorch文件夹,执行:
pip install -r requirements.txt
conda install intel::mkl-static intel::mkl-include
conda install -c pytorch magma-cuda117 # or the magma-cuda* that matches your CUDA version from https://anaconda.org/pytorch/repo
make triton
sudo apt install cmake gcc g++
conda install -c conda-forge gcc=13.2.0
export _GLIBCXX_USE_CXX11_ABI=1
export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}
4、安装编译pytorch
4.1 编译的带有CUDA支持的版本
DEBUG=1 USE_DISTRIBUTED=0 USE_MKLDNN=0 USE_CUDA=1 BUILD_TEST=0 USE_FBGEMM=0 USE_NNPACK=0 USE_QNNPACK=0 python setup.py develop
4.2 编译的不带有CUDA支持的版本
DEBUG=1 USE_DISTRIBUTED=0 USE_MKLDNN=0 USE_CUDA=0 BUILD_TEST=0 USE_FBGEMM=0 USE_NNPACK=0 USE_QNNPACK=0 python setup.py develop
二、VSCode调试
【C++编程系列】如何利用vscode调试pytorch源码(python/c++)
2024 最新PyTorch源码编译流程和踩坑记录,PyTorch build from source
Build and Develop PyTorch
pytorch源码编译,支持cuda cuDnn ,深度学习 之 源码编译
bilibili:pytorch源码编译,支持cuda cuDnn ,深度学习 之 源码编译
2024 最新PyTorch源码编译流程和踩坑记录,PyTorch build from source
Linux下VsCode调试Pytorch源码
PyTorch C++源码调试
pytorch 源码编译安装
https://github.com/pytorch/pytorch
PyTorch源码解析(先导篇)
vscode python/C++ Debug 调试 Pytorch源码