vai_q_pytorch has GPU and CPU versions. It supports PyTorch version 1.2~2.0 but does not support PyTorch data parallelism. There are two ways to install vai_q_pytorch:
Install Using Docker Containers
Vitis AI provides a Docker container for quantization tools, including vai_q_pytorch. After running a GPU or CPU container, activate the Conda environment, Vitis AI-pytorch.
conda activate vitis-ai-pytorch
vitis-ai-pytorchinstead of using
vitis-ai-pytorchdirectly. The pt_pointpillars_kitti_12000_100_10.8G_1.3 model in AMD Model Zoo is an example of this.
- Clones a Conda environment from Vitis AI-pytorch.
- Uninstalls the original PyTorch, Torchvision, and vai_q_pytorch packages.
- Installs the specified version of PyTorch, Torchvision.
- Re-installs vai_q_pytorch from source code.
Install from the Source Code
vai_q_pytorch is a Python package designed to work as a PyTorch plugin. It is an open source in Vitis_AI_Quantizer. AMD recommends to install vai_q_pytorch in the Conda environment. To do so, follow these steps:
- Add the CUDA_HOME environment variable in .bashrc.For the GPU version, if the CUDA library is installed in /usr/local/cuda, add the following line into .bashrc. If CUDA is in other directory, change the line accordingly.
export CUDA_HOME=/usr/local/cudaFor the CPU version, remove all CUDA_HOME environment variable setting in your .bashrc. It is recommended to cleanup it in command line of a shell window by running the following command:
- Install PyTorch (1.2~2.0) and Torchvision.
The following code takes PyTorch 1.7.1 and torchvision 0.8.2 as an example. You can find detailed instructions for other versions on the PyTorch website.
pip install torch==1.7.1 torchvision==0.8.2
- Install other
pip install -r requirements.txt
cd ./pytorch_binding python setup.py install
- Verify the
python -c "import pytorch_nndct"