-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinstall_TensorFlow-CPU_with_pip.sh
executable file
·103 lines (84 loc) · 2.45 KB
/
install_TensorFlow-CPU_with_pip.sh
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
#!/bin/bash
python2="python-dev"
pip2="python-pip"
python3="python3-dev"
pip3="python3-pip"
virtEnv="virtualenv"
future="future"
function installAptPackage()
{
for pkg in $1; do
if dpkg --get-selections | grep -q "^$pkg[[:space:]]*install$" >/dev/null; then
echo -e "$pkg is already installed"
else
if sudo apt-get -qq install $pkg; then
echo "Successfully installed $pkg"
else
echo "Error installing $pkg"
fi
fi
done
}
function installPipPackage()
{
echo "$1 & $2"
if [ "$1" == "2" ];
then
pip install $2 --user
else
pip3 install $2 --user
fi
}
function createVirtualEnv()
{
echo "$1"
if [ "$1" == "2" ];
then
#Install Python2 Package
installAptPackage ${python2}
#Install Python2 pip package manager
installAptPackage ${pip2}
#Install virtualenv Pip package
installPipPackage $1 ${virtEnv}
else
#Install Python3 Package
installAptPackage ${python3}
#Install Python3 pip package manager
installAptPackage ${pip3}
#Install virtualenv Pip package
installPipPackage $1 ${virtEnv}
fi
}
#MainStarts
read -r -p "Which Python Version You wanna use?[2/3.7]" response
if [ "$response" == "3" ]
then
echo "Using Python 3 Version"
createVirtualEnv "3"
else
echo "Using Python 2.7 Version"
createVirtualEnv "2"
#Install future: Fix:how-to-solve-readtimeouterror-httpsconnectionpoolhost-pypi-python-org-port
installPipPackage $response ${future}
response="2.7"
echo $response
fi
read -r -p "Give a path to create a Python virtual env without /?[eg:/home/Username]" virtPath
AcPath="$virtPath"/virtEnv_"$response"
virtualenv --system-site-packages -p python$response $AcPath
#To do:
# Activating virtual env from the bash script and installing tensorflow throwing an error
#Activate the virtual environment using a shell-specific command:
# source $AcPath/bin/activate
# #Install the TensorFlow pip package
# read -r -p "CPU or GPU Support Tensorflow?[CPU/GPU]" hwOption
# if [ "$hwOption" == "CPU" ]
# then
# #Install Tensorflow CPU
# pip install --upgrade tensorflow
# #Verify Tensorflow CPU
# python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"
# else
# echo "Hello"
# fi
# deactivate