pytorch contributing 编译

0x01 / 2024-07-12 / 原文

  1. 参考链接
    https://github.com/pytorch/pytorch/wiki/The-Ultimate-Guide-to-PyTorch-Contributions : Setup the developer environment

  2. 注意事项

  • 尽量将路由器中的代理关掉,开启本机的代理,设置好git的proxy。
  • python3 setup.py develop前检查编译环境变量的设置是否符合预期 : https://github.com/pytorch/pytorch/wiki/Development-Tips
  • 在网络出现问题时,导致python3 setup.py develop的submodule clone挂掉后,需要参考 https://github.com/pytorch/pytorch/wiki/Debugging-PyTorch-Build 链接中的命令清除构建缓存,具体如下
rm -rf build
git submodule deinit -f .
git clean -xdf
python setup.py clean
git submodule update --init --recursive # very important to sync the submodules
python setup.py develop                 # then try running the command again
  • 注意检查bashrc中系统环境变量,编译脚本setup.py会继承,可能导致编译失败。例如我遇到的cmake_find_compiler cmake unknown commands问题,解决方法:https://discuss.pytorch.org/t/can-not-build-pytorch-eiether-in-ubuntu-or-centos/147057/11?u=tk0320
  1. contributing 参考目录
    https://github.com/pytorch/pytorch/blob/main/CONTRIBUTING.md