Installation#
TorchSparse is available for Python 3.7 to Python 3.10. Before installing torchsparse, make sure that PyTorch has been successfully installed following the official guide.
Installation via Pip Wheels#
We provide pre-built torchsparse packages (recommended) with different PyTorch and CUDA versions to simplify the building for the Linux system.
Ensure that at least PyTorch 1.9.0 is installed:
python -c "import torch; print(torch.__version__)" >>> 1.10.0
Ensure PyTorch was installed with CUDA:
python -c "import torch; print(torch.version.cuda)" >>> 11.3
Then the right TorchSparse wheel can be found and installed by running the installation script:
/bin/bash -c "$(curl -fsSL https://github.com/mit-han-lab/torchsparse/blob/master/install.sh)"
Installation from Source#
You can alternatively choose to install TorchSparse from source:
TorchSparse depends on the Google Sparse Hash library.
On Ubuntu, it can be installed by:
sudo apt-get install libsparsehash-dev
On Mac OS, it can be installed by:
brew install google-sparsehash
You can also compile the library locally (if you do not have the sudo permission) and add the library path to the environment variable
CPLUS_INCLUDE_PATH.
Install Python dependencies by:
pip install -r requirements.txt
Then TorchSparse can be built from source and installed by:
pip install -e .