vai_q_pytorch has GPU and CPU versions. It supports PyTorch version 1.2-1.4 but does not support PyTorch data parallelism. There are two ways to install vai_q_pytorch:
Install using Docker Containers
The Vitis AI provides a Docker container for quantization tools, including vai_q_pytorch. After running a GPU/CPU container, activate the Conda environment, vitis-ai-pytorch.
conda activate vitis-ai-pytorch
Note: In some cases, if you
want to install some packages in the conda environment and meet permission problems,
you can create a separate conda environment based on
vitis-ai-pytorch
instead of using vitis-ai-pytorch
directly. The pt_pointpillars_kitti_12000_100_10.8G_1.3 model in Xilinx Model Zoo is an example of
this.Install from 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. It is recommended 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/cuda
For 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:unset CUDA_HOME
- Install PyTorch (1.2-1.4) and torchvision.
The following code takes PyTorch 1.4 and torchvision 0.5.0 as an example. You can find detailed instructions for other versions on the PyTorch website.
pip install torch==1.4.0 torchvision==0.5.0
- Install other
dependencies.
pip install -r requirements.txt
- Install
vai_q_pytorch.
cd ./pytorch_binding python setup.py install (for user) python setup.py develop (for developer)
- Verify the
installation.
python -c "import pytorch_nndct"