-
Notifications
You must be signed in to change notification settings - Fork 0
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
TensorFlow installer #1
base: master
Are you sure you want to change the base?
Conversation
3903a5d
to
02a087a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This review is my personal opinion, which may be one-sided, irrelevant to real goals, or blatantly wrong. I'm sorry for that. Additions for per-line comments:
- This script works for
apt-get
-based distributions of Linux only. I'm also not sure that it will work on all versions of Debian, because Debian's stable can have some pretty old software. - It does not contain any error handling at all. E.g.
apt-get
errors are ignored, and user typing errors are silently ignored. I'd suggest adding special options to the script to make it fail loudly at the very least. - Bash is known (by me :) for being very obscure and dangerous in terms of handling spaces and command line arguments in general. E.g. one should not mix
$@
,$*
, and"$@"
- all of them mean different things. Google has developed its own code style for making more robust shell scripts. I personally like their recommendations and recommend following them (or some other style guide). - I personally find bash scripts very hard to scale and debug. Basically, what you want here is to install some packages with dependencies - some subset of a package manager's functionality. Maybe writing a special metapackage is a better idea, if we aim for Debian-based systems only? Not sure at all. Some examples of probable functionality which may arise in the future:
- Detect already installed software.
- Avoid overriding existing files.
- Work under different systems without much change (e.g. use
pacman
instead ofapt-get
and slightly different package names, while still callingpip
). - Install software for a single user only and provide a separate list of global dependencies from a package manager.
- Add a UI (e.g. `dialog).
- Dynamically adjusted defaults (e.g. default to Python2 on one system and to Python3 on a newer system).
Maybe (just maybe) switching to some better programming language before it's too late would be a wise decision. Of course, one should understand final goals first.
installator.sh
Outdated
@@ -0,0 +1,68 @@ | |||
#!/bin/bash | |||
[ "$UID" -eq 0 ] || { echo "This script must be run as root."; exit 1;} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Average user may not know what is root
. I suggest adding an example command in the message.
installator.sh
Outdated
@@ -0,0 +1,68 @@ | |||
#!/bin/bash | |||
[ "$UID" -eq 0 ] || { echo "This script must be run as root."; exit 1;} | |||
echo "Determine how to install TensorFlow: " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Helpful comment like "if you don't know, choose 2" or, even better, a default option, would be nice.
installator.sh
Outdated
echo "2 'native' pip" | ||
echo "3 Docker" | ||
read mechanismId | ||
case $mechanismId in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If user mistypes or accidentally presses Enter (which happens a lot), the script will silently fail. Or, even worse: it will partially install packages and silently fail then. I suggest creating a function which re-tries reading until user types in something correctly. Or, at the very least, add an error message.
installator.sh
Outdated
read mechanismId | ||
case $mechanismId in | ||
1) | ||
sudo apt-get install python-pip python-dev python-virtualenv |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No sudo
required - we are already root. Also, what if the installation fails (e.g. no internet connection or user accidentally typed "n")? I suggest adding -u
option for bash (see general review comment). I also suggest adding -y
key for apt-get
so it does not ask the user any questions.
installator.sh
Outdated
case $mechanismId in | ||
1) | ||
sudo apt-get install python-pip python-dev python-virtualenv | ||
targetDirectory=$1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the script expects an argument. It's not obvious. I suggest adding either a comment in the very beginning, or (better) explicit check that the argument is present and it's an existing directory. Or ask for directory name right here.
installator.sh
Outdated
read pythonVersion | ||
case $pythonVersion in | ||
1) | ||
sudo -H pip uninstall tensorflow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uninstall
was not present in the first branch. Why so? Maybe you wanted --reinstall
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no such option as --reinstall
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UPD: I was absent-minded and wrote unnecessary comand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Sergey-Pravdyukov there is a similar one
installator.sh
Outdated
esac | ||
;; | ||
3) | ||
echo "Docker Community Edition for Ubuntu" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Such message is missing in previous cases and it's quite unclear. E.g. verb is lacking.
installator.sh
Outdated
echo "Docker Community Edition for Ubuntu" | ||
sudo apt-get -y install apt-transport-https ca-certificates curl | ||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | ||
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we want to install on a 32-bit system (e.g. some cheap VPS)?
installator.sh
Outdated
|
||
sudo apt-get -y install docker-ce | ||
|
||
sudo docker run hello-world |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this command is used for testing purposes, but user will only see "Hello World" and may be confused.
installator.sh
Outdated
echo "2 If you plan to run TensorFlow programs as Jupyter notebooks" | ||
echo "3 If you'd like to run TensorBoard inside the container" | ||
read usingMethod | ||
echo "Copy/paste this URL into your browser and choose Tag Name (without 'gpu' substring in the name)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd provide an example tag. Or, even better, default tag - there are four screens of tags available. How about simply taking latest-py3
as the default?
One more idea: an unexperienced user probably has little difference from a script which just chooses the first option for all questions asked. So, your installation script can be automatically (partially) tested on different supported systems, if necessary. |
4e3fb11
to
eef2c1e
Compare
In this case used command to install TensorFlow for Python 2.7