Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[MXNET-244] Fixed armv7 wheel #11053

Closed
wants to merge 10 commits into from
Closed

[MXNET-244] Fixed armv7 wheel #11053

wants to merge 10 commits into from

Conversation

lebeg
Copy link
Contributor

@lebeg lebeg commented May 24, 2018

Description

Fixes a path issue in the created by cross compilation python wheel for armv7 (RPi).

Checklist

Essentials

  • This PR starts with MXNET-244
  • Changes are complete
  • Build tests are already in place

Changes

  • Updated OpenBLAS build to align with other arm builds
  • Extracted a build_wheel function

@larroy
Copy link
Contributor

larroy commented May 24, 2018

LGTM

@@ -31,31 +31,50 @@ clean_repo() {
git submodule update --init --recursive
}

build_wheel() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea to have it centralized!

-DCMAKE_BUILD_TYPE=RelWithDebInfo\
-DUSE_MKL_IF_AVAILABLE=OFF\

# Lapack functionality will be included and statically linked to openblas.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds a bit like a hack to me. Could we have proper handling for that? Otherwise, there might be other things that depend on the USE_LAPACK flag that are not getting triggered because it's expected to be absent while it's actually there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I already tried that and this will not be easy. I suggest this will be part of a separate PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to have this within this PR as otherwise would leave the two branches in a semi-consistent state in terms of the USE_LAPACK flag until you follow up with the second PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I've said already, it is not a trivial task and can take up significant time and effort with functionality change impacting multiple builds. This PR is about fixing the ARMv7 build, for now without improvements. It is a big comment and only a few lines to keep in sync, so that it can be considered as tolerated evil. There is already a ticket to track the work on the problem: MXNET-115

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright. Since I'm not very familiar with the impact of the LAPACK-Flag (or it being absent), maybe @szha @eric-haibin-lin @piiswrong could help out here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static linking goes with openblas, but fortran needs to be linked dynamically. Comment about -static-libgfortran not working properly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway we will look into the mentioned issue above, no doubt. Do you guys see it as possible to introduce the improvement in a follow up PR?

Copy link
Contributor

@marcoabreu marcoabreu May 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@larroy I was talking about this code: https://github.com/apache/incubator-mxnet/blob/c4a76da62fbc5e3e7272fd89294fba6b22868bba/src/operator/c_lapack_api.h#L218

It seems like @lebeg and @larroy are both working on the USE_LAPACK flag. While this PR assumes the "wrong" behaviour of our build system to basically ignore the flag and set it to true(as described in the ticket), #11094 attempts to correct this. I think we should first get #11094 merged properly. After that, we actually have a USE_LAPACK behaviour that behaves like expected. This would allows us to remove the hacks we have in this PR (USE_LAPACK=0) and thus reach a clean state.

If we merge this PR first and #11094 gets merged afterwards, the LAPACK build is broken again. I'd prefer a clean solution over multiple PRs about the same issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, I'm working on a fix that will be introduced as a separate PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

@lebeg lebeg changed the title Fixed armv7 wheel [MXNET-244] Fixed armv7 wheel May 25, 2018
@@ -27,6 +27,10 @@ ENV FC /usr/bin/${CROSS_TRIPLE}-gfortran
ENV HOSTCC gcc
ENV TARGET ARMV8

RUN apt-get update && \
apt-get install -y unzip && \
rm -rf /var/lib/apt/lists/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rm -rf for apt lists is deprecated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed

@@ -25,6 +25,10 @@ ENV FC=/usr/bin/${CROSS_TRIPLE}-gfortran
ENV HOSTCC gcc
ENV TARGET ARMV6

RUN apt-get update && \
apt-get install -y unzip && \
rm -rf /var/lib/apt/lists/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rm -rf for apt lists is deprecated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -31,6 +31,10 @@ ENV FC /usr/bin/${CROSS_TRIPLE}-gfortran
ENV HOSTCC gcc
ENV TARGET ARMV8

RUN apt-get update && \
apt-get install -y unzip && \
rm -rf /var/lib/apt/lists/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rm -rf for apt lists is deprecated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@lebeg
Copy link
Contributor Author

lebeg commented May 29, 2018

@szha @marcoabreu can you have another look?

@@ -27,6 +27,8 @@ ENV FC /usr/bin/${CROSS_TRIPLE}-gfortran
ENV HOSTCC gcc
ENV TARGET ARMV8

RUN apt update && apt install -y unzip
Copy link
Contributor

@marcoabreu marcoabreu May 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we move this part (as well as the OpenBLAS compilation) for all ARM related Dockerfiles into separate scripts so that they are centralized in the install folder? As far as I can tell, they are all the same for the dependency installation (only unzip in this case) as well as for the OpenBLAS compilation.

@@ -0,0 +1,30 @@
#!/usr/bin/env bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename file to match the style of our filenames. "install_platform_action"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Platform is universal, and none of the file names have a install prefix. That gives "action" as the only needed suffix. What exactly the name you are suggesting in this case?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, it was supposed to be "install/platform_action".

I'd propose arm_openblas.sh

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not contain anything related to arm, even if we use it only for such cases.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I would have proposed something related to cross-compilation, but that might be confusing. You're right that it's not arm specific, but neither is it general :/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to keep it that way, would that be alright?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer a rename since this script is not general purpose. It's only applicable for crosscompilation. Your proposed naming would indicate that it's usable for everything.

Additionally, we only use it for crosscompilation on ARM as of now, so we should mark it accordingly. If we expand the scope later on, we're free to rename it again. For now, it's limited to the crosscompilation scope of ARM and should thus be properly named.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you see in this script as not general purpose?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PREFIX=${CROSS_ROOT} make install

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I see thanks

@@ -0,0 +1,24 @@
#!/usr/bin/env bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename file to match our filenaming style.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly the name you are suggesting in this case?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, this is fine :)

-DCMAKE_BUILD_TYPE=RelWithDebInfo\
-DUSE_MKL_IF_AVAILABLE=OFF\

# Lapack functionality will be included and statically linked to openblas.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

@larroy
Copy link
Contributor

larroy commented Jun 4, 2018

LGTM. CI is failing though. I retriggered it.

@marcoabreu
Copy link
Contributor

Please rename the install-openblas-file, then we're good to go

if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/openmp/CMakeLists.txt
AND SYSTEM_ARCHITECTURE STREQUAL "x86_64"
AND NOT MSVC
AND NOT CMAKE_CROSSCOMPILING)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is CMAKE_CROSSCOMPILING enabled/governed? For android I noticed we are not in "cross compiling" mode or whatever that is supposed to be in cmake.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, saw it below.

cd OpenBLAS && \
make -j$(nproc) && \
PREFIX=${CROSS_ROOT} make install
COPY install/ubuntu_arm.sh /work/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to copy the scripts vs running them directly from the mount volume?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we have to copy them because the volumes are not mounted during build time of the container


cmake \
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} \
-DCMAKE_CROSSCOMPILING=ON \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see :-)

@larroy
Copy link
Contributor

larroy commented Jun 6, 2018

I would like to see this merged. What else is missing?

@marcoabreu
Copy link
Contributor

"Please rename the install-openblas-file, then we're good to go"

@lebeg
Copy link
Contributor Author

lebeg commented Jun 6, 2018

I'd prefer to keep it that way, would that be alright?

@marcoabreu
Copy link
Contributor

marcoabreu commented Jun 6, 2018

Huh, how come we're adding Makefile configuration as well now? I think one buildsystem is enough, right? Also, it's not tested so I'd prefer if you remove it again

@lebeg
Copy link
Contributor Author

lebeg commented Jun 7, 2018

I have tested it to try the failure on the device. I confirm that the build works with make and cmake.

@marcoabreu
Copy link
Contributor

I think we should stick to one. So either remove cmake or make. The other one will be untested otherwise

@lebeg
Copy link
Contributor Author

lebeg commented Jun 7, 2018

It is there because we needed to build with make instead of cmake to be sure that the problems we have are not related to the build system. I suggest to remove the added file along with the others when the build will be ported to cmake completely. At the moment we have 2 working solutions for 2 of our working build systems.

@marcoabreu
Copy link
Contributor

marcoabreu commented Jun 7, 2018

Sorry I might be missing something, but where exactly are we using that new make-config? For ARMv7, I can only see cmake being used.

@lebeg
Copy link
Contributor Author

lebeg commented Jun 7, 2018

See here

@marcoabreu
Copy link
Contributor

Yeah, but it's commented. Thus, it's not tested and it should be removed.

Please elaborate in which case we need two different ways to achieve the same thing.

@lebeg
Copy link
Contributor Author

lebeg commented Jun 8, 2018

I have removed the file

@larroy
Copy link
Contributor

larroy commented Jun 8, 2018

Let's merge later from dev-arm. It includes your changes. Shall we close this PR?

@lebeg
Copy link
Contributor Author

lebeg commented Jun 14, 2018

#11245

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

Successfully merging this pull request may close these issues.

4 participants