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

Precompiled wheel #657

Closed
danielhers opened this issue Jul 3, 2017 · 14 comments
Closed

Precompiled wheel #657

danielhers opened this issue Jul 3, 2017 · 14 comments

Comments

@danielhers
Copy link
Collaborator

Installation of the master branch with pip is currently supported by pip install git+https://github.com/clab/dynet#egg=dynet.

To support installation by a simple pip install dynet (and versioning!), we need to upload a binary distribution package to PyPI. I think it would be a good idea to upload a precompiled .whl file, to reduce installation time significantly. It must be a separate file for Linux, OSX and Windows, compiled on the respective systems. I think this should be done once there is a 2.0 release.

However, I'm pretty sure it won't work with the current configuration where there is a main setup.py calling the python/setup.py which is generated from setup.py.in, because this way the main one doesn't know about the Cython extensions, and they are missing from the created wheel. Therefore, I believe the two setup.py files should be combined into a single static one, maybe replacing the CMake ${...} directives by environment variables or parameters.

@neubig
Copy link
Contributor

neubig commented Jul 3, 2017

Your assessment sounds correct, so if you could do something like that it would be greatly appreciated!

@neubig
Copy link
Contributor

neubig commented Jul 10, 2017

I've made the actual v2.0 release here, so I think it'd be great to revisit this:
https://github.com/clab/dynet/releases/tag/v2.0

@danielhers
Copy link
Collaborator Author

Great news! For now I uploaded the source distribution to PyPI, so v2.0 can already be installed by pip install dynet, but it will have to compile everything.

@danielhers
Copy link
Collaborator Author

Once #783 is merged, this should be possible by

pip install auditwheel
python setup.py bdist_wheel
setenv LD_LIBRARY_PATH $PWD/.virtualenv/lib
auditwheel repair dist/dyNET-0.0.0-cp35-cp35m-linux_x86_64.whl

auditwheel puts the libdynet.so into the wheel and fixes RPATH.

@danielhers
Copy link
Collaborator Author

When I'm trying this, I'm getting:

auditwheel: error: cannot repair "dist/dyNET-0.0.0-cp35-cp35m-linux_x86_64.whl" to "manylinux1_x86_64" ABI because of the presence of too-recent versioned symbols. You'll need to compile the wheel on an older toolchain.

Waiting for pypa/auditwheel#36 to be fixed so I know what to change in my environment.
Also, waiting for the next DyNet release before uploading to PyPI again.

@danielhers
Copy link
Collaborator Author

Using the Docker image recommended by auditwheel, I was able to build the wheel:

docker run -i -t -v `pwd`:/io quay.io/pypa/manylinux1_x86_64 /bin/bash
wget https://bitbucket.org/eigen/eigen/get/51c95eb5952b.zip
unzip 51c95eb5952b.zip
mv eigen* eigen
export EIGEN3_INCLUDE_DIR=$PWD/eigen
export MINICONDA_OS_NAME=Linux
export PYNUM=3
wget https://repo.continuum.io/miniconda/Miniconda$PYNUM-latest-$MINICONDA_OS_NAME-x86_64.sh -O miniconda.sh
bash miniconda.sh -b -p $HOME/miniconda
export PATH="$HOME/miniconda/bin:$PATH"
pip install cython auditwheel
git clone https://github.com/clab/dynet
cd dynet
export CMAKE=cmake28
python setup.py bdist_wheel
export LD_LIBRARY_PATH=$HOME/miniconda/lib
auditwheel repair dist/dyNET-0.0.0-cp36-cp36m-linux_x86_64.whl

I uploaded this to PyPI as version 2.0.1.dev1 (so it won't be automatically considered the latest stable version when installing with pip). To try it, run using Python 2.7 or 3.6 on a Linux machine:

pip install --no-cache-dir --pre dynet

@neubig
Copy link
Contributor

neubig commented Aug 29, 2017

Awesome, this is excellent! A couple things:

  1. Dp you know if there is a way to get it working on Mac OS?
  2. DyNet compiles with -march=native which compiles things for a specific processor architecture. There's a chance that things will break on other architectures, so we might need to test this.
  3. We could probably also compile with GPU support, and create a dynet-gpu package right?

(No need to handle all of these at once, just asking for clarification about possibilities.)

@danielhers
Copy link
Collaborator Author

danielhers commented Aug 29, 2017

  1. I suppose it should work for macOS too, but haven't tried it or checked about auditwheel support for it.
  2. The wheels I uploaded should be tested on different architectures to see if it works. If not, it will be necessary to compile arch-specific wheels (don't know how to do that yet).
  3. Yes, we can add a separate package for GPU. Should check what Tensorflow does.

If this works well, I'll upload an official one for the next release.

@pmichel31415
Copy link
Collaborator

I think tensorflow has a tensorflow and tensorflow-gpu package iirc

danielhers added a commit to danielhers/dynet that referenced this issue Aug 31, 2017
danielhers added a commit to danielhers/dynet that referenced this issue Aug 31, 2017
@danielhers
Copy link
Collaborator Author

By the way, is there a date planned for the next release? :)

@neubig
Copy link
Contributor

neubig commented Sep 1, 2017

I was resolving bugs that popped up due to the introduction of multi-device support, but I think we're almost finished, so maybe this weekend?

danielhers added a commit to danielhers/dynet that referenced this issue Sep 2, 2017
danielhers added a commit to danielhers/dynet that referenced this issue Sep 2, 2017
@neubig
Copy link
Contributor

neubig commented Sep 2, 2017

OK, release is done!

@danielhers
Copy link
Collaborator Author

Great! Working on the wheels.

@danielhers
Copy link
Collaborator Author

Uploaded 2.0.1 to PyPI, pre-compiled for Linux (32/64 bit) and macOS (64 bit), for Python 2.7, 3.4, 3.5 and 3.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants