Skip to content

Instantly share code, notes, and snippets.

@msaroufim
Last active January 31, 2024 23:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msaroufim/d004ad12adf1353610ad2794fb5fb858 to your computer and use it in GitHub Desktop.
Save msaroufim/d004ad12adf1353610ad2794fb5fb858 to your computer and use it in GitHub Desktop.
git clone https://github.com/pytorch/pytorch
conda install ccache -c conda-forge
pip install ninja
cd pytorch
git submodule deinit -f .
git clean -xdf
python setup.py clean
git submodule update
DEBUG=1 USE_DISTRIBUTED=0 USE_MKLDNN=0 BUILD_TEST=0 USE_FBGEMM=0 USE_NNPACK=0 USE_QNNPACK=0 USE_XNNPACK=0 USE_FLASH_ATTENTION=0 USE_MEM_EFF_ATTENTION=0 python setup.py develop
@msaroufim
Copy link
Author

msaroufim commented Jan 31, 2024

Key things to keep in mind when building PyTorch from source

  1. Use a machine with a lot of CPU cores, the more you have the faster it will build
  2. Only build what you need
  3. Cache what you can

With all of this you should be able to build PyTorch in less than 15 min

Also https://github.com/pytorch/pytorch/blob/main/CONTRIBUTING.md is long but worth just booking a few hours to read end to end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment