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

Commit

Permalink
Browse files Browse the repository at this point in the history
…bator-mxnet into perf/dropout-mask
  • Loading branch information
apeforest committed Dec 26, 2019
2 parents 0ae7a41 + 78a40d5 commit 4457579
Show file tree
Hide file tree
Showing 60 changed files with 2,606 additions and 249 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/mkldnn
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2)
cmake_minimum_required(VERSION 3.13)

# workaround to store CMAKE_CROSSCOMPILING because is getting reset by the project command
if(CMAKE_CROSSCOMPILING)
Expand Down Expand Up @@ -452,6 +452,7 @@ if(USE_OPENMP)
set(OPENMP_STANDALONE_BUILD TRUE)
set(LIBOMP_ENABLE_SHARED TRUE)
set(CMAKE_BUILD_TYPE Release)
set(OPENMP_ENABLE_LIBOMPTARGET OFF CACHE BOOL "LLVM OpenMP offloading support") # Requires CMP0077 CMake 3.13
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/openmp)
endfunction()

Expand Down
3 changes: 2 additions & 1 deletion cd/python/pypi/Jenkins_pipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// This is a temporary solution until we are confident with the packages generated by CI
// This should be removed in the not too distant future.
// We only skip the publish step so we can still QA the other variants.
pypi_releases = ["cu92", "cu92mkl"]
pypi_releases = []

def get_pipeline(mxnet_variant) {
def node_type = mxnet_variant.startsWith('cu') ? NODE_LINUX_GPU : NODE_LINUX_CPU
Expand Down Expand Up @@ -72,6 +72,7 @@ def push(mxnet_variant) {
} else {
echo "Temporarily skipping publishing PyPI package for '${mxnet_variant}'."
}
sh "./ci/docker/runtime_functions.sh cd_s3_publish"
}
}

Expand Down
21 changes: 10 additions & 11 deletions cd/python/pypi/pypi_publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ def post_wheel(path):
logging.info('Posting {} to PyPI'.format(path))
pypi_credentials = get_secret()

cmd = 'python3 -m twine upload --username {} --password {} {}'.format(
pypi_credentials['username'],
pypi_credentials['password'],
path)
cmd = 'python3 -m twine upload {}'.format(path)
version = os.path.basename(path).split('-')[1]

# The PyPI credentials for DEV has username set to 'skipPublish'
# This way we do not attempt to publish the PyPI package
Expand All @@ -47,14 +45,15 @@ def post_wheel(path):
print('In DEV account, skipping publish')
print('Would have run: {}'.format(cmd))
return 0
else:
elif any(test_version_mark in version for test_version_mark in ['a', 'b', 'dev']):
print('Skipping publishing nightly builds to Pypi.')
print('See https://github.com/pypa/pypi-support/issues/50 for details')
return 0

# DO NOT PRINT CMD IN THIS BLOCK, includes password
p = subprocess.run(cmd.split(' '),
stdout=subprocess.PIPE)
else:
env = os.environ.copy()
env['TWINE_USERNAME'] = pypi_credentials['username']
env['TWINE_PASSWORD'] = pypi_credentials['password']
p = subprocess.run(cmd.split(' '), stdout=subprocess.PIPE, env=env)
logging.info(p.stdout)
return p.returncode

Expand Down Expand Up @@ -85,7 +84,7 @@ def get_secret():
raise e
else:
return json.loads(get_secret_value_response['SecretString'])


if __name__ == '__main__':
sys.exit(post_wheel(sys.argv[1]))
48 changes: 30 additions & 18 deletions ci/build_windows.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Licensed to the Apache Software Foundation (ASF) under one
Expand Down Expand Up @@ -28,7 +28,9 @@
import platform
import shutil
import sys
import tempfile
import time
import zipfile
from distutils.dir_util import copy_tree
from enum import Enum
from subprocess import check_call
Expand Down Expand Up @@ -147,22 +149,33 @@ def windows_build(args):
mxnet_root = get_mxnet_root()
logging.info("Found MXNet root: {}".format(mxnet_root))

with remember_cwd():
os.chdir(path)
cmd = "\"{}\" && cmake -G \"NMake Makefiles JOM\" {} {}".format(args.vcvars,
CMAKE_FLAGS[args.flavour],
mxnet_root)
logging.info("Generating project with CMake:\n{}".format(cmd))
check_call(cmd, shell=True)

cmd = "\"{}\" && jom".format(args.vcvars)
logging.info("Building with jom:\n{}".format(cmd))

t0 = int(time.time())
check_call(cmd, shell=True)

logging.info("Build flavour: {} complete in directory: \"{}\"".format(args.flavour, os.path.abspath(path)))
logging.info("Build took {}".format(datetime.timedelta(seconds=int(time.time() - t0))))
url = 'https://github.com/Kitware/CMake/releases/download/v3.16.1/cmake-3.16.1-win64-x64.zip'
with tempfile.TemporaryDirectory() as tmpdir:
cmake_file_path = download_file(url, tmpdir)
with zipfile.ZipFile(cmake_file_path, 'r') as zip_ref:
# Create $tmpdir\cmake-3.16.1-win64-x64\bin\cmake.exe
zip_ref.extractall(tmpdir)

with remember_cwd():
os.chdir(path)
cmd = "\"{}\" && {} -G \"NMake Makefiles JOM\" {} {}".format(
args.vcvars,
os.path.join(tmpdir, 'cmake-3.16.1-win64-x64', 'bin', 'cmake.exe'),
CMAKE_FLAGS[args.flavour], mxnet_root)
logging.info("Generating project with CMake:\n{}".format(cmd))
check_call(cmd, shell=True)

cmd = "\"{}\" && jom".format(args.vcvars)
logging.info("Building with jom:\n{}".format(cmd))

t0 = int(time.time())
check_call(cmd, shell=True)

logging.info(
"Build flavour: {} complete in directory: \"{}\"".format(
args.flavour, os.path.abspath(path)))
logging.info("Build took {}".format(
datetime.timedelta(seconds=int(time.time() - t0))))
windows_package(args)


Expand Down Expand Up @@ -262,4 +275,3 @@ def main():

if __name__ == '__main__':
sys.exit(main())

2 changes: 1 addition & 1 deletion ci/docker/Dockerfile.build.android_armv7
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#
# Dockerfile to build MXNet for Android ARMv7

FROM mxnetcipinned/dockcross-base:11262018
FROM dockcross/base
MAINTAINER Pedro Larroy "[email protected]"

# The cross-compiling emulator
Expand Down
4 changes: 2 additions & 2 deletions ci/docker/Dockerfile.build.android_armv8
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#
# Dockerfile to build MXNet for Android ARM64/ARMv8

FROM mxnetcipinned/dockcross-base:11262018
FROM dockcross/base
MAINTAINER Pedro Larroy "[email protected]"

RUN apt-get update && apt-get install -y \
Expand Down Expand Up @@ -82,4 +82,4 @@ RUN /work/ubuntu_adduser.sh

COPY runtime_functions.sh /work/

WORKDIR /work/build
WORKDIR /work/build
2 changes: 1 addition & 1 deletion ci/docker/Dockerfile.build.armv6
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#
# Dockerfile to build MXNet for ARMv6

FROM mxnetcipinned/dockcross-linux-armv6:11262018
FROM dockcross/linux-armv6

ENV ARCH armv6l
ENV HOSTCC gcc
Expand Down
2 changes: 1 addition & 1 deletion ci/docker/Dockerfile.build.armv7
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#
# Dockerfile to build MXNet for Android ARMv7

FROM mxnetcipinned/dockcross-linux-armv7:11262018
FROM dockcross/linux-armv7

ENV ARCH armv7l
ENV HOSTCC gcc
Expand Down
2 changes: 1 addition & 1 deletion ci/docker/Dockerfile.build.armv8
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#
# Dockerfile to build MXNet for ARM64/ARMv8

FROM mxnetcipinned/dockcross-linux-arm64:11262018
FROM dockcross/linux-arm64

ENV ARCH aarch64
ENV HOSTCC gcc
Expand Down
2 changes: 1 addition & 1 deletion ci/docker/Dockerfile.build.jetson
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

FROM nvidia/cuda:9.0-cudnn7-devel as cudabuilder

FROM mxnetcipinned/dockcross-linux-arm64:11262018
FROM dockcross/linux-arm64

ENV ARCH aarch64
ENV HOSTCC gcc
Expand Down
4 changes: 2 additions & 2 deletions ci/docker/install/requirements
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ h5py==2.8.0rc1
mock==2.0.0
nose==1.3.7
nose-timer==0.7.3
numpy>1.16.0,<2.0.0
numpy>1.16.0,<1.18.0
pylint==2.3.1; python_version >= '3.0'
requests<2.19.0,>=2.18.4
scipy==1.0.1
scipy==1.2.1
six==1.11.0
9 changes: 4 additions & 5 deletions ci/docker/install/ubuntu_core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,10 @@ apt-get install -y \
ln -s /usr/lib/x86_64-linux-gnu/libturbojpeg.so.0.1.0 /usr/lib/x86_64-linux-gnu/libturbojpeg.so


# Note: we specify an exact cmake version to work around a cmake 3.10 CUDA 10 issue.
# Reference: https://github.com/clab/dynet/issues/1457
# CMake 3.13.2+ is required
mkdir /opt/cmake && cd /opt/cmake
wget -nv https://cmake.org/files/v3.12/cmake-3.12.4-Linux-x86_64.sh
sh cmake-3.12.4-Linux-x86_64.sh --prefix=/opt/cmake --skip-license
wget -nv https://cmake.org/files/v3.13/cmake-3.13.5-Linux-x86_64.sh
sh cmake-3.13.5-Linux-x86_64.sh --prefix=/opt/cmake --skip-license
ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake
rm cmake-3.12.4-Linux-x86_64.sh
rm cmake-3.13.5-Linux-x86_64.sh
cmake --version
9 changes: 9 additions & 0 deletions ci/docker/runtime_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2065,6 +2065,15 @@ cd_pypi_publish() {
./cd/python/pypi/pypi_publish.py `readlink -f wheel_build/dist/*.whl`
}

cd_s3_publish() {
set -ex
pip3 install --user awscli
filepath=$(readlink -f wheel_build/dist/*.whl)
filename=$(basename $file_path)
variant=$(echo $filename | cut -d'-' -f1 | cut -d'_' -f2 -s)
aws s3 cp --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers,full=id=43f628fab72838a4f0b929d7f1993b14411f4b0294b011261bc6bd3e950a6822 s3://apache-mxnet/dist/${variant}/${filename}
}

build_static_scala_mkl() {
set -ex
pushd .
Expand Down
33 changes: 32 additions & 1 deletion ci/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@
# specific language governing permissions and limitations
# under the License.

import os
import contextlib
import logging
import logging.config
import os
import subprocess
import sys

import requests


def get_mxnet_root() -> str:
curpath = os.path.abspath(os.path.dirname(__file__))
Expand Down Expand Up @@ -130,3 +133,31 @@ def config_logging():
# or sensitive information
logging.getLogger("botocore").setLevel(logging.WARNING)
logging.getLogger("requests").setLevel(logging.WARNING)


# Takes url and downloads it to the dest_path directory on Windows.
def download_file(url, dest_path):
file_name = url.split('/')[-1]
full_path = "{}\\{}".format(dest_path, file_name)
logging.info("Downloading: {}".format(full_path))
r = requests.get(url, stream=True)
if r.status_code == 404:
return r.status_code
elif r.status_code != 200:
logging.error("{} returned status code {}".format(url, r.status_code))
with open(full_path, 'wb') as f:
for chunk in r.iter_content(chunk_size=1024):
if chunk: # filter out keep-alive new chunks
f.write(chunk)
return full_path


# Takes arguments and runs command on host. Shell is disabled by default.
def run_command(args, shell=False):
try:
logging.info("Issuing command: {}".format(args))
res = subprocess.check_output(args, shell=shell, timeout=1800).decode("utf-8").replace("\r\n", "")
logging.info("Output: {}".format(res))
except subprocess.CalledProcessError as e:
raise RuntimeError("command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))
return res
2 changes: 1 addition & 1 deletion example/quantization/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This folder contains examples of quantizing a FP32 model with Intel® MKL-DNN or

<h2 id="1">Model Quantization with Intel® MKL-DNN</h2>

Intel® MKL-DNN supports quantization with subgraph features on Intel® CPU Platform and can bring performance improvements on the [Intel® Xeon® Scalable Platform](https://www.intel.com/content/www/us/en/processors/xeon/scalable/xeon-scalable-platform.html). A new quantization script `imagenet_gen_qsym_mkldnn.py` has been designed to launch quantization for image-classification models with Intel® MKL-DNN. This script integrates with [Gluon-CV modelzoo](https://gluon-cv.mxnet.io/model_zoo/classification.html), so that more pre-trained models can be downloaded from Gluon-CV and then converted for quantization. To apply quantization flow to your project directly, please refer [Quantize custom models with MKL-DNN backend](https://mxnet.apache.org/tutorials/mkldnn/mkldnn_quantization.html).
Intel® MKL-DNN supports quantization with subgraph features on Intel® CPU Platform and can bring performance improvements on the [Intel® Xeon® Scalable Platform](https://www.intel.com/content/www/us/en/processors/xeon/scalable/xeon-scalable-platform.html). A new quantization script `imagenet_gen_qsym_mkldnn.py` has been designed to launch quantization for image-classification models with Intel® MKL-DNN. This script integrates with [Gluon-CV modelzoo](https://gluon-cv.mxnet.io/model_zoo/classification.html), so that more pre-trained models can be downloaded from Gluon-CV and then converted for quantization. To apply quantization flow to your project directly, please refer [Quantize custom models with MKL-DNN backend](https://mxnet.apache.org/api/python/docs/tutorials/performance/backend/mkldnn/mkldnn_quantization.html).

```
usage: imagenet_gen_qsym_mkldnn.py [-h] [--model MODEL] [--epoch EPOCH]
Expand Down
Loading

0 comments on commit 4457579

Please sign in to comment.