-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure_component.py
More file actions
66 lines (51 loc) · 2.36 KB
/
configure_component.py
File metadata and controls
66 lines (51 loc) · 2.36 KB
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
import argparse
import subprocess
import os
parser = argparse.ArgumentParser(description='welcome')
parser.add_argument('--tfversion', '-tfv', choices=['lite', 'normal'], required=True,
help='specify the version of the app you want to use "')
if os.geteuid() != 0:
exit("You need to have root privileges to run this script.\nPlease try again, this time using 'sudo'. Exiting.")
args = parser.parse_args()
tfversion = args.tfversion
command = subprocess.run(['apt-get', 'install',
'lshw',
'libjpeg-dev',
'python3-pip',
'libatlas-base-dev',
'libopenjp2-7',
'libtiff5', '-y'],
stdout=subprocess.PIPE)
print(command.stdout.decode().rstrip())
command = subprocess.run(['uname', '-m'], stdout=subprocess.PIPE)
architecture = command.stdout.decode().rstrip()
if "x86_64" in architecture or "aarch64" in architecture or "armv7l" in architecture:
print("Processor "+architecture+" supported")
else:
print("Processors not supported")
exit()
command = subprocess.run(['python3', '-V'], stdout=subprocess.PIPE)
python_version = command.stdout.decode().rstrip()
version = ""
if "3.6" in python_version:
version = "cp36-cp36m"
elif "3.7" in python_version:
version = "cp37-cp37m"
else:
print("Python version not supported")
exit()
print("Python version "+version+" supported")
tensorflow_lite = "https://dl.google.com/coral/python/tflite_runtime-2.1.0-"+version+"-linux_"+architecture+".whl"
subprocess.run(['python3', '-m', 'pip', 'install', '--upgrade', 'pip'], stdout=subprocess.PIPE)
print("Installing Python dependencies")
if tfversion == 'lite':
print("Tensorflow Lite Version selected")
subprocess.run(['python3', '-m', 'pip', 'install', '-r', './setup/tensorflow_lite_version_requirements.txt'],
stdout=subprocess.PIPE)
subprocess.run(['python3', '-m', 'pip', 'install', tensorflow_lite], stdout=subprocess.PIPE)
else:
print("Tensorflow Version selected")
if architecture == "aarch64":
print("Tensorflow compilation not granted. An error can occur.")
subprocess.run(['python3', '-m', 'pip', 'install', '-r', './setup/tensorflow_version_requirements.txt'], stdout=subprocess.PIPE)
print("Installation procedure complete")