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

TensorFlow installer #1

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Conversation

Sergey-Pravdyukov
Copy link
Collaborator

In this case used command to install TensorFlow for Python 2.7

@Sergey-Pravdyukov Sergey-Pravdyukov force-pushed the CPU_supported_installer branch from 3903a5d to 02a087a Compare March 7, 2017 14:08
@Sergey-Pravdyukov Sergey-Pravdyukov changed the title Installer with virtualenv mechanism Installer with virtualenv and native 'pip' mechanisms Mar 12, 2017
@Sergey-Pravdyukov Sergey-Pravdyukov changed the title Installer with virtualenv and native 'pip' mechanisms Installer with some mechanisms Mar 12, 2017
Copy link

@yeputons yeputons left a 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:

  1. 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.
  2. 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.
  3. 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).
  4. 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 of apt-get and slightly different package names, while still calling pip).
  • 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;}

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: "

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

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

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

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

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?

Copy link
Collaborator Author

@Sergey-Pravdyukov Sergey-Pravdyukov Mar 18, 2017

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.

Copy link
Collaborator Author

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

installator.sh Outdated
esac
;;
3)
echo "Docker Community Edition for Ubuntu"

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"

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

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)"

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?

@yeputons
Copy link

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.

@Sergey-Pravdyukov Sergey-Pravdyukov force-pushed the CPU_supported_installer branch from 4e3fb11 to eef2c1e Compare March 19, 2017 10:33
@Sergey-Pravdyukov Sergey-Pravdyukov changed the title Installer with some mechanisms C Mar 21, 2017
@Sergey-Pravdyukov Sergey-Pravdyukov changed the title C CPU supported installer Mar 21, 2017
@Sergey-Pravdyukov Sergey-Pravdyukov changed the title CPU supported installer TensorFlow installer Apr 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants