tensorflow / haskell

Haskell bindings for TensorFlow
https://tensorflow.github.io/haskell/haddock/
Apache License 2.0
1.58k stars 196 forks source link

Installation #213

Open b1g3ar5 opened 6 years ago

b1g3ar5 commented 6 years ago

I followed your installation instructions but when I call:

stack --docker --docker-image=$IMAGE_NAME setup

I get:

AesonException "Error in $.packages.cassava.constraints.flags['bytestring--lt-0_10_4']: Invalid flag name: \"bytestring--lt-0_10_4\""

Any ideas?

Thanks.

N

PS: stack --version = 1.7.1

judah commented 6 years ago

That sounds like https://github.com/commercialhaskell/stackage/issues/2759 . I thought it was fixed in newer stack but am not certain off the top of my head. Maybe there's something that needs to be updated in the docker image?

blackgnezdo commented 6 years ago

@b1g3ar5 the best I can do given the information you provided is run the instructions from our README to the letter and let you spot the difference between my output below and the one you get. It really is better to over-communicate than under.

$ cat /etc/issue
Ubuntu 16.04.5 LTS \n \l
$ docker --version
Docker version 17.03.2-ce, build f5ec1e2
$ stack --version
Version 1.7.1, Git revision 681c800873816c022739ca7ed14755e85a579565 (5807 commits) x86_64 hpack-0.28.2
$ git clone --recursive https://github.com/tensorflow/haskell.git tensorflow-haskell
Cloning into 'tensorflow-haskell'...
remote: Counting objects: 2783, done.        
remote: Compressing objects: 100% (194/194), done.        
remote: Total 2783 (delta 250), reused 329 (delta 207), pack-reused 2368        
Receiving objects: 100% (2783/2783), 5.41 MiB | 0 bytes/s, done.
Resolving deltas: 100% (1775/1775), done.
Checking connectivity... done.
Submodule 'third_party/tensorflow' (https://github.com/tensorflow/tensorflow.git) registered for path 'third_party/tensorflow'
Cloning into 'third_party/tensorflow'...
remote: Counting objects: 418147, done.        
remote: Compressing objects: 100% (9/9), done.        
remote: Total 418147 (delta 1), reused 8 (delta 0), pack-reused 418138        
Receiving objects: 100% (418147/418147), 246.58 MiB | 44.21 MiB/s, done.
Resolving deltas: 100% (333597/333597), done.
Checking connectivity... done.
Submodule path 'third_party/tensorflow': checked out '25c197e02393bd44f50079945409009dd4d434f8'
$ cd tensorflow-haskell
$ IMAGE_NAME=tensorflow/haskell:v0
$ docker build -t $IMAGE_NAME docker
Sending build context to Docker daemon 5.632 kB
Step 1/7 : FROM tensorflow/tensorflow:1.9.0
 ---> caab7ec02690
Step 2/7 : LABEL maintainer "TensorFlow authors <tensorflow-haskell@googlegroups.com>"
 ---> Using cache
 ---> aeaf300cf0e8
Step 3/7 : RUN apt-get update
 ---> Using cache
 ---> a563fe661f73
Step 4/7 : RUN apt-get install -y         libsnappy-dev         libncurses5-dev         libgmp-dev         locales         netbase
 ---> Using cache
 ---> 81403ff78515
Step 5/7 : RUN dpkg-reconfigure locales &&     locale-gen en_US.UTF-8 &&     update-locale LANG=en_US.UTF-8
 ---> Using cache
 ---> 64346e68e8b5
Step 6/7 : RUN curl -O -L https://github.com/google/protobuf/releases/download/v3.2.0/protoc-3.2.0-linux-x86_64.zip &&     unzip -d /usr/local protoc-3.2.0-linux-x86_64.zip bin/protoc &&     chmod 755 /usr/local/bin/protoc &&     curl -O https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-1.9.0.tar.gz &&     tar zxf libtensorflow-cpu-linux-x86_64-1.9.0.tar.gz -C /usr/local &&     ldconfig
 ---> Using cache
 ---> a67a8af5aab2
Step 7/7 : ENV LANG en_US.UTF-8
 ---> Using cache
 ---> d3d29aa9aff5
Successfully built d3d29aa9aff5
$ stack --docker --docker-image=$IMAGE_NAME setup
stack will use a sandboxed GHC it installed
For more information on paths, see 'stack path' and 'stack exec env'
To use this GHC and packages outside of a project, consider using:
stack ghc, stack ghci, stack runghc, or stack exec

The test command after that is working too.

b1g3ar5 commented 6 years ago

Thanks for the quick reply. Here is my version of the above. There are 2 differences - I need sudo on the docker calls and stack tells me to add --allow-different-user. I wonder if it's these permissions sthat are causing the problem...

nick@nick-tt ~ $ cd workspace
nick@nick-tt ~/workspace $ cat /etc/issue
Linux Mint 18.2 Sonya \n \l

nick@nick-tt ~/workspace $ docker --version
Docker version 17.03.2-ce, build f5ec1e2
nick@nick-tt ~/workspace $ stack --version
Version 1.7.1, Git revision 681c800873816c022739ca7ed14755e85a579565 (5807 commits) x86_64 hpack-0.28.2
nick@nick-tt ~/workspace $ git clone --recursive https://github.com/tensorflow/haskell.git tensorflow-haskell
Cloning into 'tensorflow-haskell'...
remote: Counting objects: 2783, done.
remote: Compressing objects: 100% (194/194), done.
remote: Total 2783 (delta 250), reused 329 (delta 207), pack-reused 2368
Receiving objects: 100% (2783/2783), 5.41 MiB | 4.65 MiB/s, done.
Resolving deltas: 100% (1775/1775), done.
Checking connectivity... done.
Submodule 'third_party/tensorflow' (https://github.com/tensorflow/tensorflow.git) registered for path 'third_party/tensorflow'
Cloning into 'third_party/tensorflow'...
remote: Counting objects: 418274, done.
remote: Compressing objects: 100% (120/120), done.
remote: Total 418274 (delta 30), reused 83 (delta 9), pack-reused 418144
Receiving objects: 100% (418274/418274), 247.13 MiB | 4.91 MiB/s, done.
Resolving deltas: 100% (333631/333631), done.
Checking connectivity... done.
Submodule path 'third_party/tensorflow': checked out '25c197e02393bd44f50079945409009dd4d434f8'
nick@nick-tt ~/workspace $ cd tensorflow-haskellnick@nick-tt ~/workspace/tensorflow-haskell $ IMAGE_NAME=tensorflow/haskell:v0
nick@nick-tt ~/workspace/tensorflow-haskell $ sudo docker build -t $IMAGE_NAME docker
[sudo] password for nick: 
Sending build context to Docker daemon 5.632 kB
Step 1/7 : FROM tensorflow/tensorflow:1.9.0
 ---> caab7ec02690
Step 2/7 : LABEL maintainer "TensorFlow authors <tensorflow-haskell@googlegroups.com>"
 ---> Using cache
 ---> dbcd4c2c9ed2
Step 3/7 : RUN apt-get update
 ---> Using cache
 ---> 088a8c6ac0eb
Step 4/7 : RUN apt-get install -y         libsnappy-dev         libncurses5-dev         libgmp-dev         locales         netbase
 ---> Using cache
 ---> f64575371b10
Step 5/7 : RUN dpkg-reconfigure locales &&     locale-gen en_US.UTF-8 &&     update-locale LANG=en_US.UTF-8
 ---> Using cache
 ---> b7a7f66a903a
Step 6/7 : RUN curl -O -L https://github.com/google/protobuf/releases/download/v3.2.0/protoc-3.2.0-linux-x86_64.zip &&     unzip -d /usr/local protoc-3.2.0-linux-x86_64.zip bin/protoc &&     chmod 755 /usr/local/bin/protoc &&     curl -O https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-1.9.0.tar.gz &&     tar zxf libtensorflow-cpu-linux-x86_64-1.9.0.tar.gz -C /usr/local &&     ldconfig
 ---> Using cache
 ---> d4c68e3c5bbe
Step 7/7 : ENV LANG en_US.UTF-8
 ---> Using cache
 ---> 40c0e6d69836
Successfully built 40c0e6d69836
nick@nick-tt ~/workspace/tensorflow-haskell $ sudo stack --docker --docker-image=$IMAGE_NAME setup
You are not the owner of '/home/nick/.stack/'. Aborting to protect file permissions.
Retry with '--allow-different-user' to disable this precaution.
nick@nick-tt ~/workspace/tensorflow-haskell $ sudo stack --docker --docker-image=$IMAGE_NAME setup --allow-different-user
Downloaded lts-11.9 build plan.    
AesonException "Error in $.packages.cassava.constraints.flags['bytestring--lt-0_10_4']: Invalid flag name: \"bytestring--lt-0_10_4\""
nick@nick-tt ~/workspace/tensorflow-haskell $ 
blackgnezdo commented 6 years ago

I suspect different filesystem permissions and running things as root could do it. Did you consider making docker accept jobs from non-root users? At least temporarily to see if it makes a difference?

b1g3ar5 commented 6 years ago

I ran as root and I didn't need sudo or get prompted for --allow-different-user, but I still got the same error...

nick-tt workspace # cd tensorflow-haskell
nick-tt tensorflow-haskell # IMAGE_NAME=tensorflow/haskell:v0
nick-tt tensorflow-haskell # docker build -t $IMAGE_NAME docker
Sending build context to Docker daemon 5.632 kB
Step 1/7 : FROM tensorflow/tensorflow:1.9.0
 ---> caab7ec02690
Step 2/7 : LABEL maintainer "TensorFlow authors <tensorflow-haskell@googlegroups.com>"
 ---> Using cache
 ---> dbcd4c2c9ed2
Step 3/7 : RUN apt-get update
 ---> Using cache
 ---> 088a8c6ac0eb
Step 4/7 : RUN apt-get install -y         libsnappy-dev         libncurses5-dev         libgmp-dev         locales         netbase
 ---> Using cache
 ---> f64575371b10
Step 5/7 : RUN dpkg-reconfigure locales &&     locale-gen en_US.UTF-8 &&     update-locale LANG=en_US.UTF-8
 ---> Using cache
 ---> b7a7f66a903a
Step 6/7 : RUN curl -O -L https://github.com/google/protobuf/releases/download/v3.2.0/protoc-3.2.0-linux-x86_64.zip &&     unzip -d /usr/local protoc-3.2.0-linux-x86_64.zip bin/protoc &&     chmod 755 /usr/local/bin/protoc &&     curl -O https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-1.9.0.tar.gz &&     tar zxf libtensorflow-cpu-linux-x86_64-1.9.0.tar.gz -C /usr/local &&     ldconfig
 ---> Using cache
 ---> d4c68e3c5bbe
Step 7/7 : ENV LANG en_US.UTF-8
 ---> Using cache
 ---> 40c0e6d69836
Successfully built 40c0e6d69836
nick-tt tensorflow-haskell # stack --docker --docker-image=$IMAGE_NAME setup
Downloaded lts-11.9 build plan.    
AesonException "Error in $.packages.cassava.constraints.flags['bytestring--lt-0_10_4']: Invalid flag name: \"bytestring--lt-0_10_4\""
nick-tt tensorflow-haskell # 

It's a shame because I was hoping not to have to use python...

N

schnecki commented 5 years ago

You have to upgrade stack:

$ stack upgrade 

And ensure that the upgraded stack version is actually on the PATH and being used with stack --version.

caissalover commented 5 years ago

I'm facing the exact same error with stack 1.9.3

I think that installing tensorflow or tensorflow-gpu should be trivial. I too use sudo and --allow-different-user. Using things like docker to install tf should be secondary and focus should be on "cabal install tensorflow-gpu-1.13.1", a simple no-brainer installation.

@blackgnezdo

blackgnezdo commented 5 years ago

I also prefer simple things. Unfortunately TF is not a simple system to integrate with. The stack recipe is used by our CI so we know it works.

Some things I don't know off-hand how to solve: protoc dependency, tensorflow dependency. Both are outside of Haskell ecosystem and aren't first class in Cabal. They are somewhat manageable in docker and that's why we use it.

I'm open to merging any PRs making cabal install a viable route.