forked from ROCm/MIVisionX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MIVisionX-setup.py
578 lines (528 loc) · 24.7 KB
/
MIVisionX-setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
# Copyright (c) 2018 - 2024 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import os
import sys
import argparse
import platform
import traceback
if sys.version_info[0] < 3:
import commands
else:
import subprocess
__copyright__ = "Copyright 2018 - 2024, AMD ROCm MIVisionX"
__license__ = "MIT"
__version__ = "3.4.0"
__email__ = "[email protected]"
__status__ = "Shipping"
# error check calls
def ERROR_CHECK(call):
status = call
if(status != 0):
print('ERROR_CHECK failed with status:'+str(status))
traceback.print_stack()
exit(status)
# Arguments
parser = argparse.ArgumentParser()
parser.add_argument('--directory', type=str, default='~/mivisionx-deps',
help='Setup home directory - optional (default:~/)')
parser.add_argument('--opencv', type=str, default='4.6.0',
help='OpenCV Version - optional (default:4.6.0)')
parser.add_argument('--ffmpeg', type=str, default='OFF',
help='FFMPEG Installation - optional (default:OFF) [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('--amd_rpp', type=str, default='ON',
help='MIVisionX amd_rpp Dependency Install - optional (default:ON) [options:ON/OFF]')
parser.add_argument('--developer', type=str, default='OFF',
help='Setup Developer Options - optional (default:OFF) [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:HIP/CPU/OCL]')
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()
setupDir = args.directory
opencvVersion = args.opencv
ffmpegInstall = args.ffmpeg.upper()
neuralNetInstall = args.neural_net.upper()
inferenceInstall = args.inference.upper()
amdRPPInstall = args.amd_rpp.upper()
developerInstall = args.developer.upper()
reinstall = args.reinstall.upper()
backend = args.backend.upper()
ROCM_PATH = args.rocm_path
# override default path if env path set
if "ROCM_PATH" in os.environ:
ROCM_PATH = os.environ.get('ROCM_PATH')
print("\nROCm PATH set to -- "+ROCM_PATH+"\n")
# check developer inputs
if ffmpegInstall not in ('OFF', 'ON'):
print(
"ERROR: FFMPEG Install Option Not Supported - [Supported Options: OFF or ON]\n")
parser.print_help()
exit()
if neuralNetInstall not in ('OFF', 'ON'):
print(
"ERROR: Neural Net Install Option Not Supported - [Supported Options: OFF or ON]\n")
parser.print_help()
exit()
if inferenceInstall not in ('OFF', 'ON'):
print(
"ERROR: Inference Install Option Not Supported - [Supported Options: OFF or ON]\n")
parser.print_help()
exit()
if amdRPPInstall not in ('OFF', 'ON'):
print(
"ERROR: Neural Net Install Option Not Supported - [Supported Options: OFF or ON]\n")
parser.print_help()
exit()
if developerInstall not in ('OFF', 'ON'):
print(
"ERROR: Developer Option Not Supported - [Supported Options: OFF or ON]\n")
exit()
if reinstall not in ('OFF', 'ON'):
print(
"ERROR: Re-Install Option Not Supported - [Supported Options: OFF or ON]\n")
parser.print_help()
exit()
if backend not in ('OCL', 'HIP', 'CPU'):
print(
"ERROR: Backend Option Not Supported - [Supported Options: CPU or OCL or HIP]\n")
parser.print_help()
exit()
# check ROCm installation
if os.path.exists(ROCM_PATH) and backend != 'CPU':
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: If ROCm installed, set ROCm Path with \"--rocm_path\" option for full installation [Default:/opt/rocm]\n")
print("WARNING: Limited dependencies will be installed\n")
backend = 'CPU'
else:
print("\nSTATUS: CPU Backend Install\n")
neuralNetInstall = 'OFF'
inferenceInstall = 'OFF'
# get platfrom info
platfromInfo = platform.platform()
# sudo requirement check
sudoLocation = ''
userName = ''
if sys.version_info[0] < 3:
status, sudoLocation = commands.getstatusoutput("which sudo")
if sudoLocation != '/usr/bin/sudo':
status, userName = commands.getstatusoutput("whoami")
else:
status, sudoLocation = subprocess.getstatusoutput("which sudo")
if sudoLocation != '/usr/bin/sudo':
status, userName = subprocess.getstatusoutput("whoami")
# Setup Directory for Deps
if setupDir == '~/mivisionx-deps':
setupDir_deps = setupDir
else:
setupDir_deps = setupDir+'/mivisionx-deps'
# setup directory path
deps_dir = os.path.expanduser(setupDir_deps)
deps_dir = os.path.abspath(deps_dir)
# check os version
os_info_data = 'NOT Supported'
if os.path.exists('/etc/os-release'):
with open('/etc/os-release', 'r') as os_file:
os_info_data = os_file.read().replace('\n', ' ')
os_info_data = os_info_data.replace('"', '')
# setup for Linux
linuxSystemInstall = ''
linuxCMake = 'cmake'
linuxSystemInstall_check = ''
linuxFlag = ''
sudoValidate = 'sudo -v'
if "centos" in os_info_data or "redhat" in os_info_data:
linuxSystemInstall = 'yum -y'
linuxSystemInstall_check = '--nogpgcheck'
if "VERSION_ID=7" in os_info_data:
linuxCMake = 'cmake3'
sudoValidate = 'sudo -k'
platfromInfo = platfromInfo+'-redhat-7'
elif "VERSION_ID=8" in os_info_data:
platfromInfo = platfromInfo+'-redhat-8'
elif "VERSION_ID=9" in os_info_data:
platfromInfo = platfromInfo+'-redhat-9'
else:
platfromInfo = platfromInfo+'-redhat-centos-undefined-version'
elif "Ubuntu" in os_info_data:
linuxSystemInstall = 'apt-get -y'
linuxSystemInstall_check = '--allow-unauthenticated'
linuxFlag = '-S'
if "VERSION_ID=20" in os_info_data:
platfromInfo = platfromInfo+'-Ubuntu-20'
elif "VERSION_ID=22" in os_info_data:
platfromInfo = platfromInfo+'-Ubuntu-22'
elif "VERSION_ID=24" in os_info_data:
platfromInfo = platfromInfo+'-Ubuntu-24'
else:
platfromInfo = platfromInfo+'-Ubuntu-undefined-version'
elif "SLES" in os_info_data:
linuxSystemInstall = 'zypper -n'
linuxSystemInstall_check = '--no-gpg-checks'
platfromInfo = platfromInfo+'-SLES'
elif "Mariner" in os_info_data:
linuxSystemInstall = 'tdnf -y'
linuxSystemInstall_check = '--nogpgcheck'
platfromInfo = platfromInfo+'-Mariner'
else:
print("\nMIVisionX Setup on "+platfromInfo+" is unsupported\n")
print("\nMIVisionX Setup Supported on: Ubuntu 20/22, RedHat 8/9, & SLES 15\n")
exit()
# MIVisionX Setup
print("\nMIVisionX Setup on: "+platfromInfo+"\n")
if userName == 'root':
ERROR_CHECK(os.system(linuxSystemInstall+' update'))
ERROR_CHECK(os.system(linuxSystemInstall+' install sudo'))
# Delete previous install
if os.path.exists(deps_dir) and reinstall == 'ON':
ERROR_CHECK(os.system(sudoValidate))
ERROR_CHECK(os.system('sudo rm -rf '+deps_dir))
print("\nMIVisionX Setup: Removing Previous Install -- "+deps_dir+"\n")
# source install - package dependencies
libpkgConfig = "pkg-config"
if "centos" in os_info_data and "VERSION_ID=7" in os_info_data:
libpkgConfig = "pkgconfig"
commonPackages = [
'gcc',
'cmake',
'git',
'wget',
'unzip',
str(libpkgConfig),
'inxi'
]
neuralNetDebianPackages = [
'half',
'rocblas-dev',
'miopen-hip-dev',
'migraphx-dev'
]
inferenceDebianPackages = [
'python3-dev',
'python3-pip',
'protobuf-compiler',
'libprotoc-dev'
]
neuralNetRPMPackages = [
'half',
'rocblas-devel',
'miopen-hip-devel',
'migraphx-devel'
]
libPythonProto = "python3-protobuf"
if "centos" in os_info_data and "VERSION_ID=7" in os_info_data:
libPythonProto = "protobuf-python"
inferenceRPMPackages = [
'python3-devel',
'python3-pip',
'protobuf-devel',
str(libPythonProto)
]
pip3InferencePackagesUbuntu = [
'future==0.18.2',
'pytz==2022.1',
'numpy==1.23.0',
'google==3.0.0',
'protobuf==3.12.4',
'onnx==1.12.0'
]
pipNumpyVersion = "numpy==1.23.0"
if "VERSION_ID=7" in os_info_data or "VERSION_ID=8" in os_info_data:
pipNumpyVersion = "numpy==1.19.5"
pip3InferencePackagesRPM = [
'future==0.18.2',
'pytz==2022.1',
str(pipNumpyVersion),
'google==3.0.0',
'protobuf==3.12.4',
'onnx==1.11.0'
]
ffmpegDebianPackages = [
'ffmpeg',
'libavcodec-dev',
'libavformat-dev',
'libavutil-dev',
'libswscale-dev'
]
rppDebianPackages = [
'rpp',
'rpp-dev'
]
rppRPMPackages = [
'rpp',
'rpp-devel'
]
rocdecodeDebianPackages = [
'rocdecode',
'rocdecode-dev'
]
rocdecodeRPMPackages = [
'rocdecode',
'rocdecode-devel'
]
opencvDebianPackages = [
'build-essential',
'pkg-config',
'libgtk2.0-dev',
'libavcodec-dev',
'libavformat-dev',
'libswscale-dev',
'libtbb2',
'libtbb-dev',
'libjpeg-dev',
'libpng-dev',
'libtiff-dev',
'libdc1394-dev',
'unzip'
]
opencvRPMPackages = [
'gtk2-devel',
'libjpeg-devel',
'libpng-devel',
'libtiff-devel',
'libavc1394',
'unzip'
]
# update
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall +' '+linuxSystemInstall_check+' update'))
# Re-Install
if os.path.exists(deps_dir):
print("\nMIVisionX Setup: Re-Installing Libraries from -- "+deps_dir+"\n")
# common packages
for i in range(len(commonPackages)):
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall +
' '+linuxSystemInstall_check+' install -y '+ commonPackages[i]))
if "centos-7" in platfromInfo or "redhat-7" in platfromInfo:
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall +
' '+linuxSystemInstall_check+' install cmake3'))
# neural net packages
if neuralNetInstall == 'ON' and backend == 'HIP':
ERROR_CHECK(os.system(sudoValidate))
if "Ubuntu" in platfromInfo:
for i in range(len(neuralNetDebianPackages)):
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall +
' '+linuxSystemInstall_check+' install -y '+ neuralNetDebianPackages[i]))
else:
for i in range(len(neuralNetRPMPackages)):
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall +
' '+linuxSystemInstall_check+' install -y '+ neuralNetRPMPackages[i]))
# RPP
if "Ubuntu" in platfromInfo:
for i in range(len(rppDebianPackages)):
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall +
' '+linuxSystemInstall_check+' install -y '+ rppDebianPackages[i]))
else:
for i in range(len(rppRPMPackages)):
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall +
' '+linuxSystemInstall_check+' install -y '+ rppRPMPackages[i]))
# rocDecode
if "Ubuntu" in platfromInfo:
for i in range(len(rocdecodeDebianPackages)):
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall +
' '+linuxSystemInstall_check+' install -y '+ rocdecodeDebianPackages[i]))
elif "redhat-7" not in platfromInfo:
for i in range(len(rocdecodeRPMPackages)):
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall +
' '+linuxSystemInstall_check+' install -y '+ rocdecodeRPMPackages[i]))
print("\nMIVisionX Dependencies Re-Installed with MIVisionX-setup.py V-"+__version__+" on "+platfromInfo+"\n")
exit()
# Clean Install
else:
print("\nMIVisionX Dependencies Installation with MIVisionX-setup.py V-"+__version__+"\n")
ERROR_CHECK(os.system('mkdir '+deps_dir))
# Create Build folder
ERROR_CHECK(os.system('(cd '+deps_dir+'; mkdir build )'))
# install pre-reqs
ERROR_CHECK(os.system(sudoValidate))
# common packages
for i in range(len(commonPackages)):
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall +
' '+linuxSystemInstall_check+' install -y '+ commonPackages[i]))
if "centos-7" in platfromInfo or "redhat-7" in platfromInfo:
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall +
' '+linuxSystemInstall_check+' install cmake3'))
# neural net packages
if neuralNetInstall == 'ON' and backend == 'HIP':
ERROR_CHECK(os.system(sudoValidate))
if "Ubuntu" in platfromInfo:
for i in range(len(neuralNetDebianPackages)):
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall +
' '+linuxSystemInstall_check+' install -y '+ neuralNetDebianPackages[i]))
else:
for i in range(len(neuralNetRPMPackages)):
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall +
' '+linuxSystemInstall_check+' install -y '+ neuralNetRPMPackages[i]))
# Install Model Compiler Deps
if inferenceInstall == 'ON':
modelCompilerDeps = os.path.expanduser('~/.mivisionx-model-compiler-deps')
# Delete previous install
if os.path.exists(modelCompilerDeps) and reinstall == 'ON':
ERROR_CHECK(os.system(sudoValidate))
ERROR_CHECK(os.system('sudo rm -rf '+modelCompilerDeps))
print("\nMIVisionX Setup: Removing Previous Inference Install -- "+modelCompilerDeps+"\n")
if not os.path.exists(modelCompilerDeps):
print("STATUS: Model Compiler Deps Install - " +modelCompilerDeps+"\n")
os.makedirs(modelCompilerDeps)
ERROR_CHECK(os.system(sudoValidate))
if "Ubuntu" in platfromInfo:
for i in range(len(inferenceDebianPackages)):
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall +
' '+linuxSystemInstall_check+' install -y '+ inferenceDebianPackages[i]))
# Install base Deps
for i in range(len(pip3InferencePackagesUbuntu)):
ERROR_CHECK(os.system('sudo pip3 install '+ pip3InferencePackagesUbuntu[i]))
else:
for i in range(len(inferenceRPMPackages)):
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall +
' '+linuxSystemInstall_check+' install -y '+ inferenceRPMPackages[i]))
# Install base Deps
for i in range(len(pip3InferencePackagesRPM)):
ERROR_CHECK(os.system('sudo pip3 install '+ pip3InferencePackagesRPM[i]))
# Install NNEF Deps
ERROR_CHECK(os.system('mkdir -p '+modelCompilerDeps+'/nnef-deps'))
ERROR_CHECK(os.system(
'(cd '+modelCompilerDeps+'/nnef-deps; git clone -b nnef-v1.0.0 https://github.com/KhronosGroup/NNEF-Tools.git)'))
ERROR_CHECK(os.system(
'(cd '+modelCompilerDeps+'/nnef-deps/NNEF-Tools/parser/cpp; mkdir -p build && cd build; '+linuxCMake+' ..; make -j$(nproc); sudo make install)'))
ERROR_CHECK(os.system(
'(cd '+modelCompilerDeps+'/nnef-deps/NNEF-Tools/parser/python; sudo python3 setup.py install)'))
else:
print("STATUS: Model Compiler Deps Pre-Installed - " +modelCompilerDeps+"\n")
else:
print("\nSTATUS: MIVisionX Setup: Neural Network only supported with HIP backend\n")
if amdRPPInstall == 'ON' and backend == 'HIP':
# RPP
if "Ubuntu" in platfromInfo:
for i in range(len(rppDebianPackages)):
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall +
' '+linuxSystemInstall_check+' install -y '+ rppDebianPackages[i]))
else:
for i in range(len(rppRPMPackages)):
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall +
' '+linuxSystemInstall_check+' install -y '+ rppRPMPackages[i]))
else:
print("\nSTATUS: MIVisionX Setup: AMD VX RPP only supported with HIP backend\n")
# rocDecode
if "Ubuntu" in platfromInfo:
for i in range(len(rocdecodeDebianPackages)):
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall +
' '+linuxSystemInstall_check+' install -y '+ rocdecodeDebianPackages[i]))
elif "redhat-7" not in platfromInfo:
for i in range(len(rocdecodeRPMPackages)):
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall +
' '+linuxSystemInstall_check+' install -y '+ rocdecodeRPMPackages[i]))
# Install ffmpeg
if ffmpegInstall == 'ON':
if "Ubuntu" in platfromInfo:
for i in range(len(ffmpegDebianPackages)):
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall +
' '+linuxSystemInstall_check+' install -y '+ ffmpegDebianPackages[i]))
elif "centos-7" in platfromInfo or "redhat-7" in platfromInfo:
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' '+linuxSystemInstall_check +
' install epel-release'))
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' '+linuxSystemInstall_check +
' localinstall --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm'))
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' '+linuxSystemInstall_check +
' install ffmpeg ffmpeg-devel'))
elif "centos-8" in platfromInfo or "redhat-8" in platfromInfo:
# el8 x86_64 packages
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' '+linuxSystemInstall_check +
' install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm'))
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' '+linuxSystemInstall_check +
' install https://download1.rpmfusion.org/free/el/rpmfusion-free-release-8.noarch.rpm https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-8.noarch.rpm'))
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' '+linuxSystemInstall_check +
' install http://mirror.centos.org/centos/8/PowerTools/x86_64/os/Packages/SDL2-2.0.10-2.el8.x86_64.rpm'))
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' '+linuxSystemInstall_check +
' install ffmpeg ffmpeg-devel'))
elif "centos-9" in platfromInfo or "redhat-9" in platfromInfo:
# el9 x86_64 packages
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' '+linuxSystemInstall_check +
' install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm'))
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' '+linuxSystemInstall_check +
' install https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-9.noarch.rpm'))
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' '+linuxSystemInstall_check +
' install --nogpgcheck https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-$(rpm -E %rhel).noarch.rpm'))
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' '+linuxSystemInstall_check +
' install https://mirrors.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-$(rpm -E %rhel).noarch.rpm'))
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' '+linuxSystemInstall_check +
' install ffmpeg ffmpeg-free-devel'))
elif "SLES" in platfromInfo:
# FFMPEG-4 packages
ERROR_CHECK(os.system(
'sudo zypper ar -cfp 90 \'https://ftp.gwdg.de/pub/linux/misc/packman/suse/openSUSE_Leap_$releasever/Essentials\' packman-essentials'))
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' '+linuxSystemInstall_check +
' install ffmpeg-4'))
# Install OpenCV -- TBD cleanup
ERROR_CHECK(os.system('(cd '+deps_dir+'/build; mkdir OpenCV )'))
# Install pre-reqs
ERROR_CHECK(os.system(sudoValidate))
if "Ubuntu" in platfromInfo:
for i in range(len(opencvDebianPackages)):
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall +
' '+linuxSystemInstall_check+' install -y '+ opencvDebianPackages[i]))
else:
if "centos" in platfromInfo or "redhat" in platfromInfo:
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' '+linuxSystemInstall_check +
' groupinstall \'Development Tools\''))
elif "SLES" in platfromInfo:
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' '+linuxSystemInstall_check +
' install -t pattern devel_basis'))
for i in range(len(opencvRPMPackages)):
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall +
' '+linuxSystemInstall_check+' install -y '+ opencvRPMPackages[i]))
# OpenCV 4.6.0
# Get Source and install
ERROR_CHECK(os.system(
'(cd '+deps_dir+'; wget https://github.com/opencv/opencv/archive/'+opencvVersion+'.zip )'))
ERROR_CHECK(os.system('(cd '+deps_dir+'; unzip '+opencvVersion+'.zip )'))
ERROR_CHECK(os.system('(cd '+deps_dir+'/build/OpenCV; '+linuxCMake +
' -D WITH_GTK=ON -D WITH_JPEG=ON -D BUILD_JPEG=ON -D WITH_OPENCL=OFF -D WITH_OPENCLAMDFFT=OFF -D WITH_OPENCLAMDBLAS=OFF -D WITH_VA_INTEL=OFF -D WITH_OPENCL_SVM=OFF -D CMAKE_INSTALL_PREFIX=/usr/local ../../opencv-'+opencvVersion+' )'))
ERROR_CHECK(os.system('(cd '+deps_dir+'/build/OpenCV; make -j$(nproc))'))
ERROR_CHECK(os.system(sudoValidate))
ERROR_CHECK(os.system('(cd '+deps_dir+'/build/OpenCV; sudo make install)'))
ERROR_CHECK(os.system('(cd '+deps_dir+'/build/OpenCV; sudo ldconfig)'))
if developerInstall == 'ON':
ERROR_CHECK(os.system(sudoValidate))
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' '+linuxSystemInstall_check +
' install autoconf texinfo wget'))
if "Ubuntu" in platfromInfo:
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' '+linuxSystemInstall_check +
' install build-essential libgmp-dev'))
else:
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' '+linuxSystemInstall_check +
' install gmp-devel'))
ERROR_CHECK(os.system('sudo '+linuxFlag+' '+linuxSystemInstall+' '+linuxSystemInstall_check +
' groupinstall \'Development Tools\' '))
ERROR_CHECK(os.system(
'(cd '+deps_dir+'; wget https://ftp.gnu.org/gnu/gdb/gdb-12.1.tar.gz )'))
ERROR_CHECK(os.system('(cd '+deps_dir+'; tar -xvzf gdb-12.1.tar.gz )'))
ERROR_CHECK(os.system(
'(cd '+deps_dir+'/gdb-12.1; ./configure --with-python3; make CXXFLAGS="-static-libstdc++" -j$(nproc); sudo make install)'))
print("\nMIVisionX Dependencies Installed with MIVisionX-setup.py V-"+__version__+" on "+platfromInfo+"\n")