From 00b540042d07c41e060b8736bfa27fb14bc7cc63 Mon Sep 17 00:00:00 2001 From: Leonard Lausen Date: Sat, 15 Feb 2020 06:00:48 +0000 Subject: [PATCH 1/7] Fix transformer.cu interleaved matmul for cuda arch < 5 (#17596) cublasGemmBatchedEx is only supported for GPU with architecture capabilities equal or greater than 5.0. Fixes a bug in #16408 --- src/operator/contrib/transformer.cu | 71 ++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 12 deletions(-) diff --git a/src/operator/contrib/transformer.cu b/src/operator/contrib/transformer.cu index e152669478dd..59029eae65c2 100644 --- a/src/operator/contrib/transformer.cu +++ b/src/operator/contrib/transformer.cu @@ -50,18 +50,65 @@ void CublasStridedBatchedGemm(mshadow::Stream* s, bool transA, bool transB, << "Must init CuBLAS handle in stream"; cublasHandle_t blas_handle = mshadow::Stream::GetBlasHandle(s); - auto err = CUBLAS_STATUS_SUCCESS; - // TODO(cfujitsang): handle computation_precision - err = cublasGemmStridedBatchedEx( - blas_handle, CublasTransposeOp(transA), CublasTransposeOp(transB), - static_cast(m), static_cast(n), static_cast(k), - reinterpret_cast(&alpha), - a, CublasType::kCudaFlag, static_cast(lda), strideA, - b, CublasType::kCudaFlag, static_cast(ldb), strideB, - reinterpret_cast(&beta), - c, CublasType::kCudaFlag, static_cast(ldc), strideC, - static_cast(batchCount), CUDA_R_32F, algo); - CHECK_EQ(err, CUBLAS_STATUS_SUCCESS) << "Cublas gemmEx fail."; + // cublasGemmStridedBatchedEx is only supported for GPU with architecture + // capabilities equal or greater than 5.0. Fall back to + // cublasSgemmStridedBatched, which doesn't support implicit conversion + // to half-precision to use TensorCores + auto cc_major = (s->prop).major; + if (cc_major >= 5) { + CUBLAS_CALL(cublasGemmStridedBatchedEx( + blas_handle, CublasTransposeOp(transA), CublasTransposeOp(transB), + static_cast(m), static_cast(n), static_cast(k), + reinterpret_cast(&alpha), + a, CublasType::kCudaFlag, static_cast(lda), strideA, + b, CublasType::kCudaFlag, static_cast(ldb), strideB, + reinterpret_cast(&beta), + c, CublasType::kCudaFlag, static_cast(ldc), strideC, + static_cast(batchCount), CUDA_R_32F, algo)); + } else { + if (std::is_same::value) { + CUBLAS_CALL(cublasSgemmStridedBatched( + blas_handle, CublasTransposeOp(transA), CublasTransposeOp(transB), + static_cast(m), static_cast(n), static_cast(k), + reinterpret_cast(&alpha), + reinterpret_cast(a), + static_cast(lda), strideA, + reinterpret_cast(b), + static_cast(ldb), strideB, + reinterpret_cast(&beta), + reinterpret_cast(c), + static_cast(ldc), strideC, + static_cast(batchCount))); + } else if (std::is_same::value) { + CUBLAS_CALL(cublasDgemmStridedBatched( + blas_handle, CublasTransposeOp(transA), CublasTransposeOp(transB), + static_cast(m), static_cast(n), static_cast(k), + reinterpret_cast(&alpha), + reinterpret_cast(a), + static_cast(lda), strideA, + reinterpret_cast(b), + static_cast(ldb), strideB, + reinterpret_cast(&beta), + reinterpret_cast(c), + static_cast(ldc), strideC, + static_cast(batchCount))); + } else if (std::is_same::value) { + CUBLAS_CALL(cublasHgemmStridedBatched( + blas_handle, CublasTransposeOp(transA), CublasTransposeOp(transB), + static_cast(m), static_cast(n), static_cast(k), + reinterpret_cast<__half*>(&alpha), + reinterpret_cast(a), + static_cast(lda), strideA, + reinterpret_cast(b), + static_cast(ldb), strideB, + reinterpret_cast<__half*>(&beta), + reinterpret_cast<__half*>(c), + static_cast(ldc), strideC, + static_cast(batchCount))); + } else { + LOG(FATAL) << "Unsupported DType in CublasStridedBatchedGemm."; + } + } #else LOG(FATAL) << "Not implemented with CUDA < 9.1"; #endif From e72d1cd54efc9ac75113158ca793fdd0b1058abc Mon Sep 17 00:00:00 2001 From: Hao Jin Date: Fri, 7 Feb 2020 19:57:53 -0800 Subject: [PATCH 2/7] pin Markdown version to 3.1 in Julia doc build (#17549) --- julia/docs/Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/julia/docs/Makefile b/julia/docs/Makefile index e42b8cdccb93..10ef0ae0b4a9 100644 --- a/julia/docs/Makefile +++ b/julia/docs/Makefile @@ -20,8 +20,12 @@ all: 'using Pkg; \ Pkg.develop(PackageSpec(name="MXNet", path = joinpath(pwd(), "..")))' julia --color=yes --project=./ ./make.jl - pip install --user pygments mkdocs mkdocs-material python-markdown-math - ~/.local/bin/mkdocs build + pip install --user Markdown==3.1 pygments mkdocs mkdocs-material python-markdown-math + export LC_ALL="C.UTF-8" + export LANG="C.UTF-8" + echo $(LC_ALL) + echo $(LANG) + LC_ALL="C.UTF-8" ~/.local/bin/mkdocs build clean: rm -rvf venv From 6caa5a2ee20b1ca27bea6b0e4380b6f8f8b526cc Mon Sep 17 00:00:00 2001 From: Aaron Markham Date: Tue, 11 Feb 2020 16:53:54 -0800 Subject: [PATCH 3/7] pin Sphinx due to autodocsumm issue with v4.2.0 (#17561) --- docs/python_docs/environment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/python_docs/environment.yml b/docs/python_docs/environment.yml index 5f66d7715af9..7d9d42d3d662 100644 --- a/docs/python_docs/environment.yml +++ b/docs/python_docs/environment.yml @@ -23,7 +23,7 @@ dependencies: - pip - python - jupyter -- sphinx +- sphinx==2.2.2 - matplotlib - notebook - pip: From 258b9a48a03d0ddce1a8c2e0bc4e48b18c10f46c Mon Sep 17 00:00:00 2001 From: Aaron Markham Date: Sun, 9 Feb 2020 21:27:29 -0800 Subject: [PATCH 4/7] pin python dependencies (#17556) --- julia/docs/Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/julia/docs/Makefile b/julia/docs/Makefile index 10ef0ae0b4a9..66f36df9e0e0 100644 --- a/julia/docs/Makefile +++ b/julia/docs/Makefile @@ -20,7 +20,12 @@ all: 'using Pkg; \ Pkg.develop(PackageSpec(name="MXNet", path = joinpath(pwd(), "..")))' julia --color=yes --project=./ ./make.jl - pip install --user Markdown==3.1 pygments mkdocs mkdocs-material python-markdown-math + pip install --user Markdown==3.1 \ + mkdocs==1.0.4 \ + mkdocs-material==4.6.0 \ + pygments==2.5.2 \ + pymdown-extensions==6.2.1 \ + python-markdown-math==0.6 export LC_ALL="C.UTF-8" export LANG="C.UTF-8" echo $(LC_ALL) From 4863f1d737173b49a9e4950444509fa5d0d6fb6a Mon Sep 17 00:00:00 2001 From: Leonard Lausen Date: Thu, 30 Jan 2020 14:00:41 -0800 Subject: [PATCH 5/7] [CI] Fix static build pipeline (#17474) --- ci/docker/install/ubuntu_publish.sh | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/ci/docker/install/ubuntu_publish.sh b/ci/docker/install/ubuntu_publish.sh index 65982eead389..e62efd5e7579 100755 --- a/ci/docker/install/ubuntu_publish.sh +++ b/ci/docker/install/ubuntu_publish.sh @@ -57,14 +57,13 @@ mv apache-maven-3.3.9/ /usr/local/maven/ update-alternatives --install /usr/bin/mvn mvn /usr/local/maven/apache-maven-3.3.9/bin/mvn 1 update-ca-certificates -f -apt-get install -y python python3 +apt-get install -y python python-pip python3 python3-pip # the version of the pip shipped with ubuntu may be too lower, install a recent version here -wget -nv https://bootstrap.pypa.io/get-pip.py -python3 get-pip.py -python2 get-pip.py +# Restrict pip version to <19 due to use of Python 3.4 on Ubuntu 14.04 +python2 -m pip install --upgrade 'pip<19' +python3 -m pip install --upgrade 'pip<19' -apt-get remove -y python3-urllib3 - -pip2 install nose cpplint==1.3.0 'numpy>1.16.0,<2.0.0' nose-timer 'requests<2.19.0,>=2.18.4' h5py==2.8.0rc1 scipy==1.0.1 boto3 -pip3 install nose cpplint==1.3.0 pylint==2.3.1 'numpy>1.16.0,<2.0.0' nose-timer 'requests<2.19.0,>=2.18.4' h5py==2.8.0rc1 scipy==1.0.1 boto3 +# Restrict numpy version to <1.18 due to use of Python 3.4 on Ubuntu 14.04 +python2 -m pip install --upgrade --ignore-installed nose cpplint==1.3.0 'numpy>1.16.0,<1.17' nose-timer 'requests<2.19.0,>=2.18.4' h5py==2.8.0rc1 scipy==1.0.1 boto3 +python3 -m pip install --upgrade --ignore-installed nose cpplint==1.3.0 pylint==2.3.1 'numpy>1.16.0,<1.18' nose-timer 'requests<2.19.0,>=2.18.4' h5py==2.8.0rc1 scipy==1.0.1 boto3 From e7b8572e3eedadc2ade186cf50dc99aea1e48802 Mon Sep 17 00:00:00 2001 From: Leonard Lausen Date: Fri, 24 Jan 2020 00:15:42 -0800 Subject: [PATCH 6/7] 1.5.x CI fixes (#17426) * Fix numpy decorator * Workaround https://github.com/pytest-dev/pytest/issues/5903 * Disable pylint warnings * Fix Edge build * Fix numpy decorator on Centos --- ci/docker/install/centos7_python.sh | 4 ++-- ci/docker/install/requirements | 1 + ci/docker/install/ubuntu_onnx.sh | 4 ++-- tools/caffe_converter/caffe_proto_utils.py | 2 +- tools/caffe_converter/convert_mean.py | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ci/docker/install/centos7_python.sh b/ci/docker/install/centos7_python.sh index 8521cde1acca..686cf14e2e3b 100755 --- a/ci/docker/install/centos7_python.sh +++ b/ci/docker/install/centos7_python.sh @@ -31,5 +31,5 @@ curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py" python2.7 get-pip.py python3.6 get-pip.py -pip2 install nose pylint numpy nose-timer requests h5py scipy==1.0.1 -pip3 install nose pylint numpy nose-timer requests h5py scipy==1.0.1 +pip2 install nose pylint numpy nose-timer requests h5py scipy==1.2.1 decorator==4.4.0 +pip3 install nose pylint numpy nose-timer requests h5py scipy==1.2.1 decorator==4.4.0 diff --git a/ci/docker/install/requirements b/ci/docker/install/requirements index fd716f5fa815..61c9ef870504 100644 --- a/ci/docker/install/requirements +++ b/ci/docker/install/requirements @@ -21,6 +21,7 @@ boto3==1.9.229 cpplint==1.3.0 Cython==0.29.7 +CommonMark==0.5.4 decorator==4.4.0 h5py==2.8.0rc1 mock==2.0.0 diff --git a/ci/docker/install/ubuntu_onnx.sh b/ci/docker/install/ubuntu_onnx.sh index 307028925b6e..1a220c7149b2 100755 --- a/ci/docker/install/ubuntu_onnx.sh +++ b/ci/docker/install/ubuntu_onnx.sh @@ -31,5 +31,5 @@ apt-get update || true apt-get install -y libprotobuf-dev protobuf-compiler echo "Installing pytest, pytest-cov, protobuf, Pillow, ONNX and tabulate ..." -pip2 install pytest==3.6.3 pytest-cov==2.5.1 protobuf==3.5.2 onnx==1.3.0 Pillow==5.0.0 tabulate==0.7.5 -pip3 install pytest==3.6.3 pytest-cov==2.5.1 protobuf==3.5.2 onnx==1.3.0 Pillow==5.0.0 tabulate==0.7.5 +pip2 install pytest==3.6.3 pytest-cov==2.5.1 protobuf==3.5.2 onnx==1.3.0 Pillow==5.0.0 tabulate==0.7.5 attrs==19.1.0 +pip3 install pytest==3.6.3 pytest-cov==2.5.1 protobuf==3.5.2 onnx==1.3.0 Pillow==5.0.0 tabulate==0.7.5 attrs==19.1.0 diff --git a/tools/caffe_converter/caffe_proto_utils.py b/tools/caffe_converter/caffe_proto_utils.py index 8d6183457637..54cd952d4443 100644 --- a/tools/caffe_converter/caffe_proto_utils.py +++ b/tools/caffe_converter/caffe_proto_utils.py @@ -196,7 +196,7 @@ def read_caffe_mean(caffe_mean_file): mean_blob.ParseFromString(f.read()) img_mean_np = np.array(mean_blob.data) - img_mean_np = img_mean_np.reshape(mean_blob.channels, mean_blob.height, mean_blob.width) + img_mean_np = img_mean_np.reshape(mean_blob.channels, mean_blob.height, mean_blob.width) # pylint: disable=too-many-function-args # swap channels from Caffe BGR to RGB img_mean_np[[0, 2], :, :] = img_mean_np[[2, 0], :, :] diff --git a/tools/caffe_converter/convert_mean.py b/tools/caffe_converter/convert_mean.py index 1a3df71d3e54..1debfe5a2ef3 100644 --- a/tools/caffe_converter/convert_mean.py +++ b/tools/caffe_converter/convert_mean.py @@ -42,7 +42,7 @@ def convert_mean(binaryproto_fname, output=None): mean_blob.ParseFromString(f.read()) img_mean_np = np.array(mean_blob.data) - img_mean_np = img_mean_np.reshape( + img_mean_np = img_mean_np.reshape( # pylint: disable=too-many-function-args mean_blob.channels, mean_blob.height, mean_blob.width ) # swap channels from Caffe BGR to RGB From 280412f0027e4b3abec3155f97e37d6780a6d4d4 Mon Sep 17 00:00:00 2001 From: Leonard Lausen Date: Sun, 16 Feb 2020 04:48:39 +0000 Subject: [PATCH 7/7] Follow redirects when downloading apache-maven-3.3.9-bin.tar.gz --- ci/docker/install/centos7_scala.sh | 4 ++-- ci/docker/install/ubuntu_publish.sh | 4 ++-- ci/docker/install/ubuntu_scala.sh | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ci/docker/install/centos7_scala.sh b/ci/docker/install/centos7_scala.sh index 5a1c4163a031..df0d7a152bb1 100755 --- a/ci/docker/install/centos7_scala.sh +++ b/ci/docker/install/centos7_scala.sh @@ -27,8 +27,8 @@ export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk export PATH=$JAVA_HOME/bin:$PATH # Build from source with Maven -curl -o apache-maven-3.3.9-bin.tar.gz http://www.eu.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz \ - || curl -o apache-maven-3.3.9-bin.tar.gz https://search.maven.org/remotecontent?filepath=org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.tar.gz +curl -o apache-maven-3.3.9-bin.tar.gz -L http://www.eu.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz \ + || curl -o apache-maven-3.3.9-bin.tar.gz -L https://search.maven.org/remotecontent?filepath=org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.tar.gz tar xzf apache-maven-3.3.9-bin.tar.gz mkdir /usr/local/maven diff --git a/ci/docker/install/ubuntu_publish.sh b/ci/docker/install/ubuntu_publish.sh index e62efd5e7579..c3517e25d50d 100755 --- a/ci/docker/install/ubuntu_publish.sh +++ b/ci/docker/install/ubuntu_publish.sh @@ -48,8 +48,8 @@ apt-get install -y git \ pkg-config \ openjdk-8-jdk -curl -o apache-maven-3.3.9-bin.tar.gz http://www.eu.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz \ - || curl -o apache-maven-3.3.9-bin.tar.gz https://search.maven.org/remotecontent?filepath=org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.tar.gz +curl -o apache-maven-3.3.9-bin.tar.gz -L http://www.eu.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz \ + || curl -o apache-maven-3.3.9-bin.tar.gz -L https://search.maven.org/remotecontent?filepath=org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.tar.gz tar xzf apache-maven-3.3.9-bin.tar.gz mkdir /usr/local/maven diff --git a/ci/docker/install/ubuntu_scala.sh b/ci/docker/install/ubuntu_scala.sh index 9115bbc8a90c..d223b8e173ae 100755 --- a/ci/docker/install/ubuntu_scala.sh +++ b/ci/docker/install/ubuntu_scala.sh @@ -40,8 +40,8 @@ apt-get install -y \ # Ubuntu 14.04 if [[ $(lsb_release -r | grep 14.04) ]]; then - curl -o apache-maven-3.3.9-bin.tar.gz http://www.eu.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz \ - || curl -o apache-maven-3.3.9-bin.tar.gz https://search.maven.org/remotecontent?filepath=org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.tar.gz + curl -o apache-maven-3.3.9-bin.tar.gz -L http://www.eu.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz \ + || curl -o apache-maven-3.3.9-bin.tar.gz -L https://search.maven.org/remotecontent?filepath=org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.tar.gz tar xzf apache-maven-3.3.9-bin.tar.gz mkdir /usr/local/maven