Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip search finds tensorflow, but pip install does not

I am trying to build a Django app that would use Keras models to make recommendations. Right now I'm trying to use one custom container that would hold both Django and Keras. Here's the Dockerfile I've written.

# myproject/docker/app/Dockerfile

FROM python:3.7-alpine  # I've tried 3.5, 3.6 and 3.7

RUN apk add --no-cache postgresql-libs && \
  apk add --no-cache --virtual .build-deps \
    gfortran \
    build-base \
    freetype-dev \
    libpng-dev \
    openblas-dev \
    postgresql-dev \
    python3-dev \
    wget

WORKDIR /app
COPY ./misc/requirements.txt /app/
RUN pip search tensorflow
RUN pip install tensorflow
RUN pip install -r /app/requirements.txt

COPY . /app

EXPOSE 8000
ENTRYPOINT ["exec /start.sh"]

Problem is, when I try to build app image, pip can't install tensorflow, even though pip search tensorflow lists tensorflow (1.12) in results.

$ docker-compose -f "docker/docker-compose.yml" --project-directory /path/to/myproject build
psql uses an image, skipping
redis uses an image, skipping
Building app
Step 1/12 : FROM python:3.7-alpine
3.7-alpine: Pulling from library/python
cd784148e348: Already exists
a5ca736b15eb: Already exists
f320f547ff02: Pull complete
2edd8ff8cb8f: Pull complete
9381128744b2: Pull complete
Digest: sha256:f708ad35a86f079e860ecdd05e1da7844fd877b58238e7a9a588b2ca3b1534d8
Status: Downloaded newer image for python:3.7-alpine
 ---> 1a8edcb29ce4
Step 2/12 : ENV PYTHONBUFFERED 1
 ---> Running in 5178b24df888
Removing intermediate container 5178b24df888
 ---> 0f928fbf30f1
Step 3/12 : RUN apk add --no-cache postgresql-libs &&   apk add --no-cache --virtual .build-deps     gfortran     build-base     freetype-dev     libpng-dev     openblas-dev     postgresql-dev     python3-dev     wget
 ---> Running in 2a8f4653e3f9
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
(1/5) Installing db (5.3.28-r0)
(2/5) Installing libsasl (2.1.26-r14)
(3/5) Installing libldap (2.4.46-r0)
(4/5) Installing libpq (10.5-r0)
(5/5) Installing postgresql-libs (10.5-r0)
OK: 19 MiB in 39 packages
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
(1/36) Installing binutils (2.30-r5)
(2/36) Installing gmp (6.1.2-r1)
(3/36) Installing isl (0.18-r0)
(4/36) Installing libgomp (6.4.0-r9)
(5/36) Installing libatomic (6.4.0-r9)
(6/36) Installing pkgconf (1.5.3-r0)
(7/36) Installing libgcc (6.4.0-r9)
(8/36) Installing mpfr3 (3.1.5-r1)
(9/36) Installing mpc1 (1.0.3-r1)
(10/36) Installing libstdc++ (6.4.0-r9)
(11/36) Installing gcc (6.4.0-r9)
(12/36) Installing libquadmath (6.4.0-r9)
(13/36) Installing libgfortran (6.4.0-r9)
(14/36) Installing gfortran (6.4.0-r9)
(15/36) Installing libmagic (5.32-r0)
(16/36) Installing file (5.32-r0)
(17/36) Installing musl-dev (1.1.19-r10)
(18/36) Installing libc-dev (0.7.1-r0)
(19/36) Installing g++ (6.4.0-r9)
(20/36) Installing make (4.2.1-r2)
(21/36) Installing fortify-headers (0.9-r0)
(22/36) Installing build-base (0.5-r1)
(23/36) Installing libpng (1.6.34-r1)
(24/36) Installing freetype (2.9.1-r1)
(25/36) Installing zlib-dev (1.2.11-r1)
(26/36) Installing libpng-dev (1.6.34-r1)
(27/36) Installing freetype-dev (2.9.1-r1)
(28/36) Installing openblas-ilp64 (0.3.0-r0)
(29/36) Installing openblas (0.3.0-r0)
(30/36) Installing openblas-dev (0.3.0-r0)
(31/36) Installing libressl-dev (2.7.4-r0)
(32/36) Installing postgresql-dev (10.5-r0)
(33/36) Installing python3 (3.6.6-r0)
(34/36) Installing python3-dev (3.6.6-r0)
(35/36) Installing wget (1.19.5-r0)
(36/36) Installing .build-deps (0)
Executing busybox-1.28.4-r2.trigger
OK: 488 MiB in 75 packages
Removing intermediate container 2a8f4653e3f9
 ---> 0a6733c0891e
Step 4/12 : WORKDIR /app
 ---> Running in e99a4dadbd78
Removing intermediate container e99a4dadbd78
 ---> 11d698c20e86
Step 5/12 : COPY ./misc/requirements.txt /app/
 ---> aa6b85587b84
Step 6/12 : RUN pip search tensorflow
 ---> Running in a4434a87e740
tensorflow (1.12.0)                                      - TensorFlow is an open source machine learning framework for everyone.
tensorflow-qndex (0.0.22)                                - tensorflow-qnd x tensorflow-extenteten
tensorflow-estimator (1.10.12)                           - TensorFlow Estimator.
mesh-tensorflow (0.0.5)                                  - Mesh TensorFlow
tensorflow-io (0.1.0)                                    - TensorFlow IO
tensorflow-plot (0.2.0)                                  - TensorFlow Plot
tensorflow-lattice (0.9.8)                               - TensorFlow Lattice provides lattice models in TensorFlow
tensorflow-datasets (0.0.2)                              - tensorflow/datasets is a library of datasets ready to use with TensorFlow.
tensorflow-extenteten (0.0.22)                           - TensorFlow extention library
cxflow-tensorflow (0.5.0)                                - TensorFlow extension for cxflow.
emloop-tensorflow (0.1.0)                                - TensorFlow extension for emloop.
tensorflow-k8s (0.0.2)                                   - Tensorflow serving extension
tensorflow-transform (0.11.0)                            - A library for data preprocessing with TensorFlow
dask-tensorflow (0.0.2)                                  - Interactions between Dask and Tensorflow
tensorflow-tracer (1.1.0)                                - Runtime Tracing Library for TensorFlow
sagemaker-tensorflow (1.12.0.1.0.0.post1)                - Amazon Sagemaker specific TensorFlow extensions.
tensorflow-qnd (0.1.11)                                  - Quick and Dirty TensorFlow command framework
tensorflow-probability (0.5.0)                           - Probabilistic modeling and statistical inference in TensorFlow
tensorflow-utils (0.1.0)                                 - Classes and methods to make using TensorFlow easier
tensorflow-model (0.1.1)                                 - Command-line tool to inspect TensorFlow models
tensorflow-lattice-gpu (0.9.8)                           - TensorFlow Lattice provides lattice models in TensorFlow
tensorflow-template (0.2)                                - A tensorflow template for quick starting a deep learning project.
tensorflow-rocm (1.12.0)                                 - TensorFlow is an open source machine learning framework for everyone.
intel-tensorflow (1.12.0)                                - TensorFlow is an open source machine learning framework for everyone.
tensorflow-font2char2word2sent2doc (0.0.12)              - TensorFlow implementation of Hierarchical Attention Networks for Document Classification
tensorflow-gpu (1.12.0)                                  - TensorFlow is an open source machine learning framework for everyone.
tensorflow-aarch64 (1.2)                                 - Tensorflow r1.2 for aarch64[arm64,pine64] CPU only.
tensorflow-fedora28 (1.9.0rc0)                           - TensorFlow is an open source machine learning framework for everyone.
tensorflow-model-analysis (0.11.0)                       - A library for analyzing TensorFlow models
tensorflow-transform-canary (0.9.0)                      - A library for data preprocessing with TensorFlow
rav-tensorflow-transform (0.7.0.910)                     - A library for data preprocessing with TensorFlow
tensorflow-serving-api (1.12.0)                          - TensorFlow Serving Python API.
tensorflow-serving-client (0.0.10)                       - Python client for tensorflow serving
tensorflow-hub (0.2.0)                                   - TensorFlow Hub is a library to foster the publication, discovery, and consumption of reusable parts of machine learning models.
tensorflow-estimator-2.0-preview (1.13.0.dev2019010100)  - TensorFlow Estimator.
ngraph-tensorflow-bridge (0.8.0)                         - Intel nGraph compiler and runtime for TensorFlow
tensorflow-probability-gpu (0.4.0)                       - Probabilistic modeling and statistical inference in TensorFlow
simple-tensorflow-serving (0.6.6)                        - The simpler and easy-to-use serving service for TensorFlow models
tensorflow-auto-detect (1.11.0)                          - Automatically install CPU or GPU tensorflow determined by looking for a CUDA installation.
tensorflow-serving-api-python3 (1.8.0)                   - *UNOFFICIAL* TensorFlow Serving API libraries for Python3
tensorflow-exercise-hx (1.0.1)                           - tensorflow练习:鸢尾花种类预测,加州房价预测
tensorflow-metadata (0.9.0)                              - Library and standards for schema and statistics.
tensorflow-tensorboard (1.5.1)                           - TensorBoard lets you watch Tensors Flow
resnet-tensorflow (0.0.1)                                - Deep Residual Neural Network
mlops-tensorflow (0.1.0)                                 - 
tensorflow-gpu-macosx (1.8.1)                            - Unoffcial NVIDIA CUDA GPU support version of Google Tensorflow for MAC OSX 10.13. For more info, please check out my github page. I highly recommend you directly download and install it from my github's release. If you insist on compiling it, you'd do it on a shell to debug.
syntaxnet-with-tensorflow (0.2)                          - SyntaxNet: Neural Models of Syntax
tensorflow-data-validation (0.11.0)                      - A library for exploring and validating machine learning data.
ogres (0.0.2)                                            - Thin tensorflow wrapper. Requires tensorflow
tfmesos (0.0.10)                                         - Tensorflow on Mesos
tf-estimator-nightly (1.12.0.dev20181217)                - TensorFlow Estimator.
TFBOYS (0.0.1)                                           - TensorFlow BOYS
TFTree (0.1.0)                                           - Tree to tensorflow
tfdebugger (0.1.1)                                       - TensorFlow Debugger
tfextras (0.0.8)                                         - Tensorflow extras
tfu (0.0.1.dev0)                                         - tensorflow utils
tnt (0.12.0.7)                                           - tnt is not tensorflow
easytf (13.9)                                            - Tensorflow CS
tftf (0.0.29)                                            - TensorFlow TransFormer
tf-datasets (0.0.1)                                      - tensorflow/datasets
tfds-nightly (0.0.2.dev201901020014)                     - tensorflow/datasets is a library of datasets ready to use with TensorFlow.
tf-common (1.0.0)                                        - A common liberary of tensorflow
ParticleFlow (0.0.1)                                     - Particle simulations with tensorflow
tf_decompose (0.1)                                       - Tensor decomposition with TensorFlow
tensorbase (0.3)                                         - Minimalistic TensorFlow Framework
miniflow (0.2.9)                                         - Minimal implementation of TensorFlow
bob.learn.tensorflow (1.0.3)                             - Bob bindings for tensorflow
quantile-transformer-tf (1.2)                            - An implementation of QuantileTransformer in tensorflow
tf-env (0.1.0)                                           - RL environments for TensorFlow.
tfseqestimator (2.2.0)                                   - Sequence estimators for Tensorflow
wavenet (0.1.2)                                          - An implementation of WaveNet for TensorFlow.
tf_kaldi_io (0.3.0)                                      - kaldi-io for Tensorflow
ptfutils (0.0.29)                                        - Useful modules for tensorflow
iceflow (0.0.1a2)                                        - tensorflow meta-framework
tf2onnx (0.3.2)                                          - Tensorflow to ONNX converter
tensorforce (0.4.3)                                      - Reinforcement learning for TensorFlow
simnets (0.0.1)                                          - SimNets implementation in tensorflow
saliency (0.0.2)                                         - Saliency methods for TensorFlow
tensor-lib (1.8.19)                                      - Simplified tensorflow library
tensorsets (0.1.0)                                       - Standard datasets for TensorFlow.
tfstage (0.1.7)                                          - TensorFlow project scaffolding
top-hat (0.0.2)                                          - Recommendation system in TensorFlow
TensorMol (0.1)                                          - TensorFlow+Molecules = TensorMol
tfshop (0.0.1)                                           - common tensorflow paradigms
kfac (0.1.0)                                             - K-FAC for TensorFlow
transferflow (0.1.8)                                     - Transfer learning for Tensorflow
train (0.0.3)                                            - Training utilities for TensorFlow.
vibranium (0.1.0)                                        - Opinionated Tensorflow projects
tf-data (0.0.4)                                          - Easy datasets for tensorflow
tensorfunk (0.0.0)                                       - tensorflow model converter to create tensorflow-independent prediction functions.
tf1 (1.1.0)                                              - F1-score metric for TensorFlow
tensorboard-easy (0.2.3)                                 - A tensorflow-independent tensorboard logger
gpflow (1.3.0)                                           - Gaussian process methods in tensorflow
layer (0.1.14)                                           - tensorflow custom comfort wrapper
tflab (0.1.3)                                            - A laboratory for experimenting with Tensorflow abstraction
tensorpack (0.9.0.1)                                     - Neural Network Toolbox on TensorFlow
tensorflowservingclient (0.5.1.post2)                    - Prebuilt tensorflow serving client
EasyFlow (0.1.dev3)                                      - Modular Distributed TensorFlow Framework
tfgraph (0.2)                                            - Python's Tensorflow Graph Library
serving-utils (0.6.0)                                    - Some utilities for tensorflow serving
Removing intermediate container a4434a87e740
 ---> a14248285cb2
Step 7/12 : RUN pip install tensorflow
 ---> Running in 2c14fe29c431
Collecting tensorflow
  Could not find a version that satisfies the requirement tensorflow (from versions: )
No matching distribution found for tensorflow
ERROR: Service 'app' failed to build: The command '/bin/sh -c pip install tensorflow' returned a non-zero code: 1

Do I have to resort to building tensorflow from source?

EDIT
Writing this question made me realize I could use two separate containers: one for my Django app and a prebuilt tensorflow with gpu. I would still like to learn how to resolve issues like this, but any pointers to docs how to make two separate docker containers talk, would be appreciated.

like image 664
julka Avatar asked Mar 04 '23 19:03

julka


1 Answers

It looks like tensorflow only publishes wheels (and only up to 3.6), and Alpine linux is not manylinux1-compatible due to its use of musl instead of glibc. Because of this, pip cannot find a suitable installation candidate and fails. Your best options are probably to build from source or change your base image.

like image 90
jonafato Avatar answered Mar 12 '23 20:03

jonafato