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

Cannot install torch 0.4.1.post2 on python:3.7-alpine #341

Closed
JesseTG opened this issue Oct 1, 2018 · 8 comments
Closed

Cannot install torch 0.4.1.post2 on python:3.7-alpine #341

JesseTG opened this issue Oct 1, 2018 · 8 comments
Labels
question Usability question, not directly related to an error with the image

Comments

@JesseTG
Copy link

JesseTG commented Oct 1, 2018

I'm trying to install PyTorch version 0.4.1 on the python:3.7-alpine image. However, pip3.7 only sees 0.1.2:

/ # pip3.7 install --no-cache-dir torch
Collecting torch
  Downloading https://files.pythonhosted.org/packages/5f/e9/bac4204fe9cb1a002ec6140b47f51affda1655379fe302a1caef421f9846/torch-0.1.2.post1.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-xg7fjq4l/torch/setup.py", line 11, in <module>
        raise RuntimeError(README)
    RuntimeError: PyTorch does not currently provide packages for PyPI (see status at https://github.com/pytorch/pytorch/issues/566).
    
    Please follow the instructions at http://pytorch.org/ to install with miniconda instead.
    
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-xg7fjq4l/torch/
/ # 

And yet, when searching for torch...

/ # pip3.7 search torch
<snip for brevity>
torch (0.4.1.post2)        - Tensors and Dynamic neural networks in Python with strong GPU acceleration
<snip for brevity>
/ # 

...you see that pip3.7 finds version 0.4.1.post2.

@wglambert wglambert added the question Usability question, not directly related to an error with the image label Oct 1, 2018
@wglambert
Copy link

I'm not familiar with python; it seems for the latest version the download is offered in a .whl format which "is not a supported wheel on this platform". However 0.1.2.post1 is offered in .tar.gz so I'm assuming pip is detecting the platform and only allowing compatible installs.
https://packaging.python.org/tutorials/installing-packages/#source-distributions-vs-wheels

On the debian variant the package installs correctly, I might also add that the package is quite large relative to the base image at 497MB compressed; eclipsing the benefit of using an alpine base for the purpose of a smaller size.

$ ls -lh
total 620M
-rw-rw-r-- 1 rei rei  28M Oct  1 11:26 python:3.7-alpine.tar.gz
-rw-rw-r-- 1 rei rei  48M Oct  1 11:23 python:3.7-slim-stretch.tar.gz
-rw-rw-r-- 1 rei rei 545M Oct  1 11:27 pytorch-python:3.7-slim-stretch.tar.gz

@JesseTG
Copy link
Author

JesseTG commented Oct 1, 2018

I don't understand much about how Python software is actually packaged and distributed, but why wouldn't a wheel be supported on Alpine?

@wglambert
Copy link

Alpine uses a different libc: musl, compared to glibc. And the .whl format is not compatible with musl. And also that some packages for pip are only offered in .whl format
docker-library/docs#904
pypa/manylinux#37
pypa/pip#3969

https://github.com/pypa/manylinux

The manylinux1 tags allow projects to distribute wheels that are automatically installed (and work!) on the vast majority of desktop and server Linux distributions.

Docs on the alpine image variant
https://github.com/docker-library/docs/tree/master/python#pythonversion-alpine

@JayH5
Copy link
Contributor

JayH5 commented Oct 1, 2018

To be clear, manylinux1 wheels with native extensions can't be installed on Alpine Linux. Wheels that are pure Python code (none wheels) work just fine on Alpine.

If you add the --verbose flag to your pip command you can see it rejecting the other wheels and versions.

@JesseTG
Copy link
Author

JesseTG commented Oct 1, 2018

I see. So you can't do anything about this issue without doing one of the following:

  1. Adding support for a slim distribution that uses glibc instead of musl
  2. Adding musl support to pytorch
  3. Making a glibc-based alpine

Is my assessment correct?

@JayH5
Copy link
Contributor

JayH5 commented Oct 1, 2018

  1. Adding support for a slim distribution that uses glibc instead of musl

The python:3.7-slim-stretch image that @wglambert suggested is "slim" and uses glibc. I would also recommend that you use an image like that.

  1. Adding musl support to pytorch

It's not that PyTorch definitely doesn't support musl, it just doesn't build packages for it. There also isn't a Python wheel format that can be uploaded to PyPI that supports musl. You could probably compile PyTorch from source for Alpine if you really wanted to but it probably wouldn't be worth the effort.

  1. Making a glibc-based alpine

While such a thing does exist, I wouldn't recommend it as it can cause all kinds of problems. One of the major things in Alpine that makes it so small is that it uses musl and not glibc. You may as well just use one of the Debian-based slim images.

@tianon
Copy link
Member

tianon commented Oct 2, 2018

(Closing, since there's nothing more we can do here.)

@tianon tianon closed this as completed Oct 2, 2018
@JesseTG
Copy link
Author

JesseTG commented Oct 2, 2018

Thank you anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Usability question, not directly related to an error with the image
Projects
None yet
Development

No branches or pull requests

4 participants