Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup - Support for RedHat and Updates #1020

Merged
merged 7 commits into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
168 changes: 86 additions & 82 deletions MIVisionX-setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,18 @@
help='ProtoBuf Version - optional (default:3.12.4)')
parser.add_argument('--rpp', type=str, default='0.99',
help='RPP Version - optional (default:0.99)')
parser.add_argument('--ffmpeg', type=str, default='no',
help='FFMPEG V4.4.2 Installation - optional (default:no) [options:yes/no]')
parser.add_argument('--neural_net', type=str, default='yes',
help='MIVisionX Neural Net Dependency Install - optional (default:yes) [options:yes/no]')
parser.add_argument('--rocal', type=str, default='yes',
help='MIVisionX rocAL Dependency Install - optional (default:yes) [options:yes/no]')
parser.add_argument('--reinstall', type=str, default='no',
help='Remove previous setup and reinstall - optional (default:no) [options:yes/no]')
parser.add_argument('--ffmpeg', type=str, default='ON',
help='FFMPEG V4.4.2 Installation - optional (default:ON) [options:ON/OFF]')
parser.add_argument('--neural_net', type=str, default='ON',
help='MIVisionX Neural Net Dependency Install - optional (default:ON) [options:ON/OFF]')
parser.add_argument('--inference', type=str, default='ON',
help='MIVisionX Neural Net Inference Dependency Install - optional (default:ON) [options:ON/OFF]')
parser.add_argument('--rocal', type=str, default='ON',
help='MIVisionX rocAL Dependency Install - optional (default:ON) [options:ON/OFF]')
parser.add_argument('--reinstall', type=str, default='OFF',
help='Remove previous setup and reinstall - optional (default:OFF) [options:ON/OFF]')
parser.add_argument('--backend', type=str, default='HIP',
help='MIVisionX Dependency Backend - optional (default:HIP) [options:CPU/OCL/HIP]')
help='MIVisionX Dependency Backend - optional (default:HIP) [options:HIP/OCL/CPU]')
parser.add_argument('--rocm_path', type=str, default='/opt/rocm',
help='ROCm Installation Path - optional (default:/opt/rocm) - ROCm Installation Required')
args = parser.parse_args()
Expand All @@ -65,6 +67,7 @@
rppVersion = args.rpp
ffmpegInstall = args.ffmpeg
neuralNetInstall = args.neural_net
inferenceInstall = args.inference
rocalInstall = args.rocal
reinstall = args.reinstall
backend = args.backend
Expand All @@ -74,42 +77,47 @@
ROCM_PATH = os.environ.get('ROCM_PATH')
print("\nROCm PATH set to -- "+ROCM_PATH+"\n")

if ffmpegInstall not in ('no', 'yes'):
if ffmpegInstall not in ('OFF', 'ON'):
print(
"ERROR: FFMPEG Install Option Not Supported - [Supported Options: no or yes]")
"ERROR: FFMPEG Install Option Not Supported - [Supported Options: OFF or ON]")
exit()
if neuralNetInstall not in ('no', 'yes'):
if neuralNetInstall not in ('OFF', 'ON'):
print(
"ERROR: Neural Net Install Option Not Supported - [Supported Options: no or yes]")
"ERROR: Neural Net Install Option Not Supported - [Supported Options: OFF or ON]")
exit()
if rocalInstall not in ('no', 'yes'):
if inferenceInstall not in ('OFF', 'ON'):
print(
"ERROR: Neural Net Install Option Not Supported - [Supported Options: no or yes]")
"ERROR: Inference Install Option Not Supported - [Supported Options: OFF or ON]")
exit()
if reinstall not in ('no', 'yes'):
if rocalInstall not in ('OFF', 'ON'):
print(
"ERROR: Re-Install Option Not Supported - [Supported Options: no or yes]")
"ERROR: Neural Net Install Option Not Supported - [Supported Options: OFF or ON]")
exit()
if reinstall not in ('OFF', 'ON'):
print(
"ERROR: Re-Install Option Not Supported - [Supported Options: OFF or ON]")
exit()
if backend not in ('OCL', 'HIP', 'CPU'):
print(
"ERROR: Backend Option Not Supported - [Supported Options: CPU or OCL or HIP]")
exit()

# check ROCm installation
if os.path.exists(ROCM_PATH) and backend != 'CPU':
if os.path.exists(ROCM_PATH):
print("\nROCm Installation Found -- "+ROCM_PATH+"\n")
os.system('echo ROCm Info -- && '+ROCM_PATH+'/bin/rocminfo')
else:
if backend != 'CPU':
print("\nWARNING: ROCm Not Found at -- "+ROCM_PATH+"\n")
print(
"WARNING: Set ROCm Path with \"--rocm_path\" option for full installation [Default:/opt/rocm]\n")
print("WARNING: Only OpenCV will be installed\n")
print("WARNING: Limited dependencies will be installed\n")
else:
print("\nCPU Only Install: OpenCV will be installed\n")
ffmpegInstall = 'no'
neuralNetInstall = 'no'
rocalInstall = 'no'
print("\nCPU Only Install\n")
ffmpegInstall = 'OFF'
neuralNetInstall = 'OFF'
rocalInstall = 'OFF'
inferenceInstall = 'OFF'

# get platfrom info
platfromInfo = platform.platform()
Expand Down Expand Up @@ -141,12 +149,14 @@
linuxCMake = 'cmake'
linuxSystemInstall_check = ''
linuxFlag = ''
if "centos" in platfromInfo or "redhat" in platfromInfo:
if "centos" in platfromInfo or "redhat" in platfromInfo or os.path.exists('/usr/bin/yum'):
linuxSystemInstall = 'yum -y'
linuxSystemInstall_check = '--nogpgcheck'
if "centos-7" in platfromInfo or "redhat-7" in platfromInfo:
linuxCMake = 'cmake3'
os.system(linuxSystemInstall+' install cmake3')
if not "centos" in platfromInfo or not "redhat" in platfromInfo:
platfromInfo = platfromInfo+'-redhat'
elif "Ubuntu" in platfromInfo or os.path.exists('/usr/bin/apt-get'):
linuxSystemInstall = 'apt-get -y'
linuxSystemInstall_check = '--allow-unauthenticated'
Expand All @@ -159,7 +169,7 @@
platfromInfo = platfromInfo+'-SLES'
else:
print("\nMIVisionX Setup on "+platfromInfo+" is unsupported\n")
print("\nMIVisionX Setup Supported on: Ubuntu 20/22; CentOS 7/8; RedHat 7/8; & SLES 15-SP2\n")
print("\nMIVisionX Setup Supported on: Ubuntu 20/22; CentOS 7/8; RedHat 7/8/9; & SLES 15-SP2\n")
exit()

# MIVisionX Setup
Expand All @@ -170,7 +180,7 @@
os.system(linuxSystemInstall+' install sudo')

# Delete previous install
if os.path.exists(deps_dir) and reinstall == 'yes':
if os.path.exists(deps_dir) and reinstall == 'ON':
os.system('sudo -v')
os.system('sudo rm -rf '+deps_dir)
print("\nMIVisionX Setup: Removing Previous Install -- "+deps_dir+"\n")
Expand All @@ -184,7 +194,7 @@
os.system('(cd '+deps_dir+'/build/OpenCV; sudo ' +
linuxFlag+' make install -j8)')

if neuralNetInstall == 'yes' and backend != 'CPU':
if neuralNetInstall == 'ON' and backend != 'CPU':
if backend == 'OCL':
os.system('sudo -v')
os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' ' +
Expand All @@ -197,21 +207,21 @@
os.system('sudo '+linuxFlag+' '+linuxSystemInstall +
' '+linuxSystemInstall_check+' install -y --reinstall rocblas rocblas-dev miopen-hip miopen-hip-dev migraphx')

if (rocalInstall == 'yes' or neuralNetInstall == 'yes') and backend != 'CPU':
if (rocalInstall == 'ON' or neuralNetInstall == 'ON') and backend != 'CPU':
# ProtoBuf
if os.path.exists(deps_dir+'/protobuf-'+ProtoBufVersion):
os.system('sudo -v')
os.system('(cd '+deps_dir+'/protobuf-'+ProtoBufVersion +
'; sudo '+linuxFlag+' make install -j8)')

if rocalInstall == 'yes' and backend != 'CPU':
if rocalInstall == 'ON' and backend != 'CPU':
# RPP
if os.path.exists(deps_dir+'/rpp/build-'+backend):
os.system('sudo -v')
os.system('(cd '+deps_dir+'/rpp/build-'+backend+'; sudo ' +
linuxFlag+' make install -j8)')

if ffmpegInstall == 'yes' and backend != 'CPU':
if ffmpegInstall == 'ON' and backend != 'CPU':
# FFMPEG
if os.path.exists(deps_dir+'/FFmpeg-n4.4.2'):
os.system('sudo -v')
Expand All @@ -235,25 +245,25 @@
os.system(
'(cd '+deps_dir+'; wget https://github.com/opencv/opencv/archive/'+opencvVersion+'.zip )')
os.system('(cd '+deps_dir+'; unzip '+opencvVersion+'.zip )')
if (rocalInstall == 'yes' or neuralNetInstall == 'yes') and backend != 'CPU':
if (rocalInstall == 'ON' or neuralNetInstall == 'ON') and backend != 'CPU':
os.system(
'(cd '+deps_dir+'; wget https://github.com/protocolbuffers/protobuf/archive/v'+ProtoBufVersion+'.zip )')
os.system('(cd '+deps_dir+'; unzip v'+ProtoBufVersion+'.zip )')
if ffmpegInstall == 'yes' and backend != 'CPU':
if ffmpegInstall == 'ON' and backend != 'CPU':
os.system(
'(cd '+deps_dir+'; wget https://github.com/FFmpeg/FFmpeg/archive/refs/tags/n4.4.2.zip && unzip n4.4.2.zip )')

# Install
if (rocalInstall == 'yes' or neuralNetInstall == 'yes') and backend != 'CPU':
if (rocalInstall == 'ON' or neuralNetInstall == 'ON') and backend != 'CPU':
# package dependencies
os.system('sudo -v')
if "centos" in platfromInfo or "redhat" in platfromInfo:
if "centos-7" in platfromInfo or "redhat-7" in platfromInfo:
os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' ' + linuxSystemInstall_check +
' install kernel-devel libsqlite3x-devel bzip2-devel openssl-devel python3-devel autoconf automake libtool curl make g++ unzip')
elif "centos-8" in platfromInfo or "redhat-8" in platfromInfo:
elif "centos-8" in platfromInfo or "redhat" in platfromInfo:
os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' ' + linuxSystemInstall_check +
' install kernel-devel libsqlite3x-devel bzip2-devel openssl-devel python3-devel autoconf automake libtool curl make gcc-c++ unzip')
' install kernel-devel libsqlite3x-devel bzip2-devel openssl-devel python3-devel autoconf automake libtool make gcc-c++ unzip')
elif "Ubuntu" in platfromInfo:
os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' ' +
linuxSystemInstall_check+' install sqlite3 libsqlite3-dev libbz2-dev libssl-dev python3-dev autoconf automake libtool')
Expand All @@ -266,12 +276,8 @@
os.system(
'(cd '+deps_dir+'; wget https://boostorg.jfrog.io/artifactory/main/release/1.72.0/source/boost_1_72_0.tar.bz2 )')
os.system('(cd '+deps_dir+'; tar xjvf boost_1_72_0.tar.bz2 )')
if "centos-8" in platfromInfo or "redhat-8" in platfromInfo or "SLES" in platfromInfo:
os.system(
'(cd '+deps_dir+'/boost_1_72_0/; ./bootstrap.sh --prefix=/usr/local --with-python=python36 )')
else:
os.system(
'(cd '+deps_dir+'/boost_1_72_0/; ./bootstrap.sh --prefix=/usr/local --with-python=python3 )')
os.system(
'(cd '+deps_dir+'/boost_1_72_0/; ./bootstrap.sh --prefix=/usr/local --with-python=python3 )')
os.system(
'(cd '+deps_dir+'/boost_1_72_0/; ./b2 stage -j16 threading=multi link=shared cxxflags="-std=c++11" )')
os.system(
Expand Down Expand Up @@ -302,24 +308,32 @@
os.system('(cd '+deps_dir+'/protobuf-'+ProtoBufVersion +
'; sudo '+linuxFlag+' ldconfig )')

if neuralNetInstall == 'yes' and backend != 'CPU':
if neuralNetInstall == 'ON' and backend != 'CPU':
# Remove Previous Install - MIOpen
os.system('sudo -v')
if os.path.exists(ROCM_PATH+'/miopen'):
os.system('sudo rm -rf '+ROCM_PATH+'/miopen*')

if backend == 'OCL':
os.system('sudo -v')
os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' ' +
linuxSystemInstall_check+' autoremove -y rocblas rocblas-dev miopen-hip miopen-hip-dev migraphx')
if "Ubuntu" in platfromInfo:
os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' ' +
linuxSystemInstall_check+' autoremove -y rocblas rocblas-dev miopen-hip miopen-hip-dev migraphx-devel')
else:
os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' ' +
linuxSystemInstall_check+' autoremove -y rocblas rocblas-devel miopen-hip miopen-hip-devel migraphx-devel')
os.system('sudo '+linuxFlag+' '+linuxSystemInstall +
' '+linuxSystemInstall_check+' install -y miopen-opencl')
else:
os.system('sudo -v')
os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' ' +
linuxSystemInstall_check+' autoremove -y miopengemm miopen-opencl')
os.system('sudo '+linuxFlag+' '+linuxSystemInstall +
' '+linuxSystemInstall_check+' install -y miopen-hip migraphx')
if "Ubuntu" in platfromInfo:
os.system('sudo '+linuxFlag+' '+linuxSystemInstall +
' '+linuxSystemInstall_check+' install -y rocblas-dev miopen-hip-dev migraphx-dev')
else:
os.system('sudo '+linuxFlag+' '+linuxSystemInstall +
' '+linuxSystemInstall_check+' install -y rocblas-devel miopen-hip-devel migraphx-devel')

# Install OpenCV
os.system('(cd '+deps_dir+'/build; mkdir OpenCV )')
Expand Down Expand Up @@ -354,7 +368,7 @@
os.system('sudo -v')
os.system('(cd '+deps_dir+'/build/OpenCV; sudo '+linuxFlag+' ldconfig )')

if rocalInstall == 'yes' and backend != 'CPU':
if rocalInstall == 'ON' and backend != 'CPU':
# Install RPP
if "Ubuntu" in platfromInfo:
# Install Packages for rocAL
Expand All @@ -369,45 +383,35 @@
os.system('sudo -v')
os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' ' +
linuxSystemInstall_check+' install clang')
# turbo-JPEG - https://github.com/rrawther/libjpeg-turbo.git -- 2.0.6.2
os.system(
'(cd '+deps_dir+'; git clone -b 2.0.6.2 https://github.com/rrawther/libjpeg-turbo.git )')
os.system('(cd '+deps_dir+'/libjpeg-turbo; mkdir build; cd build; '+linuxCMake +
' -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RELEASE -DENABLE_STATIC=FALSE -DCMAKE_INSTALL_DEFAULT_LIBDIR=lib ..; make -j 4; sudo make install )')
# RPP
# Remove Previous Install - RPP
elif "redhat" in platfromInfo:
# Nasm & Yasm
os.system('sudo -v')
os.system('(cd '+deps_dir+'; git clone -b '+rppVersion+' https://github.com/GPUOpen-ProfessionalCompute-Libraries/rpp.git; cd rpp; mkdir build-'+backend+'; cd build-'+backend+'; ' +
linuxCMake+' -DBACKEND='+backend+' ../; make -j4; sudo make install)')
# Turn off for CentOS - TBD: TURN ON when RPP is supported on CentOS
# else:
# Nasm
# os.system('(cd '+deps_dir+'; curl -O -L https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.bz2 )')
# os.system('(cd '+deps_dir+'; tar xjvf nasm-2.14.02.tar.bz2 )')
# os.system('(cd '+deps_dir+'/nasm-2.14.02; ./autogen.sh; ./configure; make -j8 )')
# os.system('sudo -v')
# os.system('(cd '+deps_dir+'/nasm-2.14.02; sudo '+linuxFlag+' make install )')
# Yasm
# os.system('(cd '+deps_dir+'; curl -O -L https://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz )')
# os.system('(cd '+deps_dir+'; tar xzvf yasm-1.3.0.tar.gz )')
# os.system('(cd '+deps_dir+'/yasm-1.3.0; ./configure; make -j8 )')
# os.system('sudo -v')
# os.system('(cd '+deps_dir+'/yasm-1.3.0; sudo '+linuxFlag+' make install )')
os.system('sudo '+linuxFlag+' '+linuxSystemInstall +
' '+linuxSystemInstall_check+' install nasm yasm')
# JSON-cpp
# os.system('sudo -v')
# os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' '+linuxSystemInstall_check+' install jsoncpp')
os.system('sudo -v')
os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' ' +
linuxSystemInstall_check+' install jsoncpp')
# clang+boost
# os.system('sudo -v')
# os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' '+linuxSystemInstall_check+' install boost-devel clang')
# turbo-JPEG
# os.system('(cd '+deps_dir+'; wget https://downloads.sourceforge.net/libjpeg-turbo/libjpeg-turbo-2.0.3.tar.gz )')
# os.system('(cd '+deps_dir+'; tar xf libjpeg-turbo-2.0.3.tar.gz )')
# os.system('(cd '+deps_dir+'/libjpeg-turbo-2.0.3; mkdir build; cd build; '+linuxCMake+' -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RELEASE -DENABLE_STATIC=FALSE -DCMAKE_INSTALL_DOCDIR=/usr/share/doc/libjpeg-turbo-2.0.3 -DCMAKE_INSTALL_DEFAULT_LIBDIR=lib ..; make -j 4; sudo make install )')
# RPP
# os.system('(cd '+deps_dir+'; git clone -b '+rppVersion+' https://github.com/GPUOpen-ProfessionalCompute-Libraries/rpp.git; cd rpp; mkdir build; cd build; '+linuxCMake+' -DBACKEND=OCL ../; make -j4; sudo make install)')
os.system('sudo -v')
os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' ' +
linuxSystemInstall_check+' install boost-devel clang')
# lmbd
os.system('sudo -v')
os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' ' +
linuxSystemInstall_check+' install lmdb-devel')
# turbo-JPEG - https://github.com/rrawther/libjpeg-turbo.git -- 2.0.6.2
os.system(
'(cd '+deps_dir+'; git clone -b 2.0.6.2 https://github.com/rrawther/libjpeg-turbo.git )')
os.system('(cd '+deps_dir+'/libjpeg-turbo; mkdir build; cd build; '+linuxCMake +
' -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RELEASE -DENABLE_STATIC=FALSE -DCMAKE_INSTALL_DEFAULT_LIBDIR=lib ..; make -j 4; sudo make install )')
# RPP
os.system('sudo -v')
os.system('(cd '+deps_dir+'; git clone -b '+rppVersion+' https://github.com/GPUOpen-ProfessionalCompute-Libraries/rpp.git; cd rpp; mkdir build-'+backend+'; cd build-'+backend+'; ' +
linuxCMake+' -DBACKEND='+backend+' -DCMAKE_INSTALL_PREFIX='+ROCM_PATH+' ../; make -j4; sudo make install)')

# Install ffmpeg
if ffmpegInstall == 'yes' and backend != 'CPU':
if ffmpegInstall == 'ON' and backend != 'CPU':
if "Ubuntu" in platfromInfo:
os.system('sudo -v')
os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' '+linuxSystemInstall_check +
Expand Down Expand Up @@ -448,7 +452,7 @@
# libASS
os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' '+linuxSystemInstall_check +
' install libass-devel')
elif "centos-8" in platfromInfo or "redhat-8" in platfromInfo:
elif "centos-8" in platfromInfo or "redhat" in platfromInfo:
# el8 x86_64 packages
os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' '+linuxSystemInstall_check +
' install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm')
Expand Down
Loading