Skip to content

Instantly share code, notes, and snippets.

@hanxue
Created February 3, 2021 18:31
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 hanxue/8518159a3b5629caa86724c52414f7a2 to your computer and use it in GitHub Desktop.
Save hanxue/8518159a3b5629caa86724c52414f7a2 to your computer and use it in GitHub Desktop.
Vitis AI 1.3 AMI
export TZ=America/Denver
sudo ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
export VAI_ROOT=/opt/vitis_ai
export VAI_HOME=/vitis_ai_home
export LANG=en_US.UTF-8
export LANGUAGE=en_US:en
export LC_ALL=en_US.UTF-8
sudo chmod 1777 /tmp
sudo mkdir /scratch
sudo chmod 1777 /scratch
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends \
apt-transport-https \
autoconf \
automake \
bc \
build-essential \
bzip2 \
ca-certificates \
curl \
g++ \
git \
gnupg \
locales \
libboost-all-dev \
libgflags-dev \
libgoogle-glog-dev \
libgtest-dev \
libjson-c-dev \
libssl-dev \
libtool \
libunwind-dev \
make \
openssh-client \
openssl \
python3 \
python3-dev \
python3-minimal \
python3-numpy \
python3-opencv \
python3-pip \
python3-setuptools \
python3-venv \
software-properties-common \
sudo \
tree \
unzip \
vim \
wget \
yasm \
zstd
sudo sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen
sudo echo "LC_ALL=en_US.UTF-8" >> /etc/environment
sudo echo "LANG=en_US.UTF-8" > /etc/locale.conf
sudo locale-gen en_US.UTF-8
sudo localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
sudo dpkg-reconfigure locales
# Tools for building vitis-ai-library in the docker container
sudo apt-get install -y \
libavcodec-dev \
libavformat-dev \
libeigen3-dev \
libgstreamer-plugins-base1.0-dev \
libgstreamer1.0-dev \
libgtest-dev \
libgtk-3-dev \
libgtk2.0-dev \
libjpeg-dev \
libopenexr-dev \
libpng-dev \
libswscale-dev \
libtiff-dev \
libwebp-dev \
opencl-clhpp-headers \
opencl-headers \
pocl-opencl-icd \
rpm
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test \
sudo apt-get install -y \
gcc-8 \
g++-8 \
gcc-9 \
g++-9
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main'
sudo apt-get update -y
sudo apt-get install -y \
cmake=3.16.0-0kitware1 \
cmake-data=3.16.0-0kitware1 \
kitware-archive-keyring \
sudo apt-get install -y ffmpeg
cd /usr/src/gtest
mkdir -p build
cd build
cmake ..
make
sudo make install
pip3 install \
Flask \
setuptools \
wheel
# Install XRT
cd /tmp
wget --progress=dot:mega -O xrt.deb https://www.xilinx.com/bin/public/openDownload?filename=xrt_202020.2.8.726_18.04-amd64-xrt.deb
ls -lhd ./xrt.deb
sudo apt-get update -y
sudo apt-get install -y ./xrt.deb
rm -fr /tmp/*
# glog 0.4.0
cd /tmp
wget --progress=dot:mega -O glog.0.4.0.tar.gz https://codeload.github.com/google/glog/tar.gz/v0.4.0 \
tar -xvf glog.0.4.0.tar.gz
cd glog-0.4.0
./autogen.sh
mkdir build
cd build
cmake -DBUILD_SHARED_LIBS=ON ..
make -j
sudo make install
rm -fr /tmp/*
# protobuf 3.4.0
cd /tmp
wget --progress=dot:mega https://codeload.github.com/google/protobuf/zip/v3.4.0
unzip v3.4.0
cd protobuf-3.4.0
./autogen.sh
./configure
make -j
sudo make install
sudo ldconfig
rm -fr /tmp/*
# opencv 3.4.3
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
cd /tmp; wget --progress=dot:mega https://github.com/opencv/opencv/archive/3.4.3.tar.gz \
tar -xvf 3.4.3.tar.gz
cd opencv-3.4.3
mkdir build
cd build
cmake -DBUILD_SHARED_LIBS=ON ..
make -j
sudo make install
sudo ldconfig
sudo export PATH="${VAI_ROOT}/conda/bin:${VAI_ROOT}/utility:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
sudo rm -fr /tmp/*
# gflags 2.2.2
cd /tmp
wget --progress=dot:mega https://github.com/gflags/gflags/archive/v2.2.2.tar.gz
tar xvf v2.2.2.tar.gz
cd gflags-2.2.2
mkdir build
cd build
cmake -DBUILD_SHARED_LIBS=ON ..
make -j
sudo make install
rm -fr /tmp/*
# pybind 2.5.0
cd /tmp
git clone https://github.com/pybind/pybind11.git
cd pybind11
git checkout v2.5.0
mkdir build
cd build
cmake -DPYBIND11_TEST=OFF ..
make
sudo make install
rm -fr /tmp/*
sudo chmod 777 /usr/lib/python3/dist-packages
cd /tmp
wget --progress=dot:mega http://launchpadlibrarian.net/436533799/libjson-c4_0.13.1+dfsg-4_amd64.deb
sudo dpkg -i ./libjson-c4_0.13.1+dfsg-4_amd64.deb
rm -fr /tmp/*
cd /tmp
wget --progress=dot:mega http://xcogpuvai01:8000/sdk-1013.sh
chmod a+x /tmp/sdk-1013.sh
/tmp/sdk-1013.sh -y
rm -fr /tmp/*
sudo chmod 777 /opt/petalinux/2020.2/sysroots/aarch64-xilinx-linux/
echo ". $VAI_ROOT/conda/etc/profile.d/conda.sh" >> ~/.bashrc
echo "conda activate base" >> ~/.bashrc
echo 'export PS1="\[\e[91m\]Vitis-AI\[\e[m\] \w > "' >> ~/.bashrc
mkdir -p ${VAI_ROOT}
export MY_CONDA_CHANNEL=http://artifactory/artifactory/vitis-ai-release
RUN cd /tmp
wget --progress=dot:mega https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
/bin/bash ./miniconda.sh -b -p $VAI_ROOT/conda
sudo ln -s $VAI_ROOT/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh
#ADD docker/cpu_conda/*.yml /scratch/
#ADD docker/pip_requirements.txt /scratch/
#ADD docker/pip_requirements_neptune.txt /scratch/
# Create conda envs
#RUN . $VAI_ROOT/conda/etc/profile.d/conda.sh \
# && python3 -m pip install --upgrade pip wheel setuptools \
# && conda env create -f /scratch/vitis-ai-pytorch.yml \
# && conda activate vitis-ai-pytorch \
# && pip install -r /scratch/pip_requirements.txt \
# && conda env create -f /scratch/vitis-ai-caffe.yml \
# && conda activate vitis-ai-caffe \
# && pip install -r /scratch/pip_requirements.txt \
# && conda env create -f /scratch/vitis-ai-tensorflow.yml \
# && conda activate vitis-ai-tensorflow \
# && pip install -r /scratch/pip_requirements.txt \
# && conda env create -f /scratch/vitis-ai-tensorflow2.yml \
# && conda activate vitis-ai-tensorflow2 \
# && pip install -r /scratch/pip_requirements.txt \
# && pip install --ignore-installed tensorflow==2.3.0 \
# && conda env create -f /scratch/vitis-ai-neptune.yml \
# && conda activate vitis-ai-neptune \
# && pip install -r /scratch/pip_requirements_neptune.txt \
# && mkdir -p $VAI_ROOT/compiler \
# && conda activate vitis-ai-caffe \
# && sudo cp -r $CONDA_PREFIX/lib/python3.6/site-packages/vaic/arch $VAI_ROOT/compiler/arch
cd /tmp/ \
&& wget -O libunilog.deb https://www.xilinx.com/bin/public/openDownload?filename=libunilog_1.3.0-r20_amd64.deb \
&& wget -O libtarget-factory.deb https://www.xilinx.com/bin/public/openDownload?filename=libtarget-factory_1.3.0-r22_amd64.deb \
&& wget -O libxir.deb https://www.xilinx.com/bin/public/openDownload?filename=libxir_1.3.0-r29_amd64.deb \
&& wget -O libvart.deb https://www.xilinx.com/bin/public/openDownload?filename=libvart_1.3.0-r53_amd64.deb \
&& wget -O libvitis_ai_library.deb https://www.xilinx.com/bin/public/openDownload?filename=libvitis%5fai%5flibrary_1.3.0-r45_amd64.deb \
&& wget -O libbutler-base.deb https://www.xilinx.com/bin/public/openDownload?filename=libbutler-base_1.3.0_amd64.deb \
&& wget -O librt-engine.deb https://www.xilinx.com/bin/public/openDownload?filename=librt-engine_1.3.0-r106_amd64.deb \
&& wget -O aks.deb https://www.xilinx.com/bin/public/openDownload?filename=aks_1.3.0-r3020_amd64.deb \
&& apt-get install -y --no-install-recommends /tmp/*.deb \
&& rm -rf /tmp/* \
&& ldconfig
sudo apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /scratch/*
# Set default build toolchain to GCC 9 for better performance
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90 \
--slave /usr/bin/g++ g++ /usr/bin/g++-9 \
--slave /usr/bin/gcov gcov /usr/bin/gcov-9 \
&& update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80 \
--slave /usr/bin/g++ g++ /usr/bin/g++-8 \
--slave /usr/bin/gcov gcov /usr/bin/gcov-8 \
&& update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70 \
--slave /usr/bin/g++ g++ /usr/bin/g++-7 \
--slave /usr/bin/gcov gcov /usr/bin/gcov-7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment