pytorch / serve

Serve, optimize and scale PyTorch models in production
https://pytorch.org/serve/
Apache License 2.0
4.15k stars 836 forks source link

Mention Java dependency in installation instructions #1796

Open tpanza opened 2 years ago

tpanza commented 2 years ago

📚 The doc issue

torchserve apparently requires Java (and, in particular, Java 17) in order to run. However, neither the README nor the Getting Started doc describe this requirement.

The closest I can find about this requirement are the Win Native and WSL docs. But anyone running on Linux would have no reason to read those docs. Furthermore, links to those Windows-related docs seem sparse.

Suggest a potential alternative/fix

Mention the need for Java to be installed, including the expected version of Java and setting the JAVA_HOME environment variable, as part of the high level installation and getting started instructions.

msaroufim commented 2 years ago

Today we do this via python ./ts_scripts/install_dependencies.py --cuda=cu102 which is mentioned in the README. Do you think it'd be best to briefly mention what this script does also in the main README?

tpanza commented 2 years ago

Thanks, @msaroufim Yes, I think the Java dependency is important enough to warrant mentioning up front in the README.

I suppose this is technically a separate issue, but the ts_scripts/install_dependencies.py does not appear to be a universal solution. For example, running apt-get install -y openjdk-17-jdk would not work for someone running on a RHEL-based distro.

msaroufim commented 2 years ago

Interesting, what did you need to do to make it work? yum? I'm happy to make install_dependencies more general for you

tpanza commented 2 years ago

Interesting, what did you need to do to make it work? I'm happy to make install_dependencies more general for you

For RHEL, this procedure is one way to install JDK. The package manager is yum, rather than apt-get. The package name is java-17-openjdk-devel, rather than openjdk-17-jdk.

Having a general Java installer sounds quite ambitious, IMO. Simply stating up front and explicitly in the docs that the users are required to install JDK17 would go a long way in the meantime. That way, they can take whatever custom steps are needed for their particular situation. The install_dependencies can be proposed as covering some, but not all, common scenarios.

As written, install_dependencies would benefit from renaming the current Linux class to DebianBasedLinuxDistro, DebianBasedLinuxDistroWithSudoPerms, or something like that.

There is another issue in that users in general will not necessarily have sudo privilege. Or if they do, they may not necessarily want to install the JDK17 at a system level.

One workaround to not having sudo is to install the JDK from conda-forge using mamba or conda. That assumes the user would have mamba or conda package managers installed and configured. If they did, though, it would be somewhat broader coverage than Debian-specific apt-get commands.

msaroufim commented 2 years ago

Interesting, lemme discuss this with @rohithkrn and get back to you - in the meantime if you'd like to make the PR to explain this better would be happy to merge it

Having a general Java installer sounds quite ambitious, IMO. Simply stating up front and explicitly in the docs that the users are required to install JDK17 would go a long way in the meantime. That way, they can take whatever custom steps are needed for their particular situation. The install_dependencies can be proposed as covering some, but not all, common scenarios.

As written, install_dependencies would benefit from renaming the current Linux class to DebianBasedLinuxDistro, DebianBasedLinuxDistroWithSudoPerms, or something like that.
ozancaglayan commented 2 years ago

I generally refrain from running dependency installer scripts unless I'm 100% sure what it does. So I think it'd be good to document all the steps performed in the install_deps also in the README file.

tpanza commented 1 year ago

@msaroufim would you accept a PR on this? A rough outline of my proposed changes:

msaroufim commented 1 year ago

Hi @tpanza

Overall I'm very open to us having more friendly installation scripts but just need to make sure docs work, that beginners still have a script where everything just gets installed but also something that provides more flexibility to advanced users

We might just need to also document the force flag a bit better https://github.com/pytorch/serve/blob/master/ts_scripts/install_dependencies.py#L200 - it's something I added sometime back when I heard similar concerns

Regardless please send over the PR, @agunapal and I would be happy to review

tpanza commented 1 year ago

Hi @msaroufim

What do you think of the following approach? Replace the existing script install_dependencies.py into two:

CaseyHaralson commented 1 year ago

Today we do this via python ./ts_scripts/install_dependencies.py --cuda=cu102 which is mentioned in the README. Do you think it'd be best to briefly mention what this script does also in the main README?

To me, the readme doesn't seem to suggest that running install_dependencies is necessary. That top block of the readme looks like it is giving options as to how to install torchserve: clone repo and install, install latest via pip, or install nightly via pip.