You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2020/06/25 22:57:20 UTC

[GitHub] [incubator-mxnet] ptrendx opened a new pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

ptrendx opened a new pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622


   ## Description ##
   As described in https://github.com/apache/incubator-mxnet/issues/18280#issuecomment-627010252, MXNet currently contains too many CUDA kernels, that affect negatively compile time, size of the resulting binary (resulting in issues like #17045 and #18205), and GPU memory consumption (as all of those kernels need to be loaded during the first GPU context creation to GPU memory).
   
   The reason of those problems is the number of templates that need to be instantiated, especially in the case of NumPy operators which need to accept different input/output types - this results in multiple nested `MSHADOW_TYPE_SWITCH` macros and great increase in the number of kernels generated, most of them pretty much never used. For example, executing this command:
   ```
   cuobjdump -symbols -arch sm_70 /usr/local/lib/python3.6/dist-packages/mxnet/libmxnet.so | grep GLOBAL | wc -l
   ```
   on the nightly build of mxnet-cu102 from 6/25 shows 69169 kernels (the same command executed on the library built with this PR at the time of writing gives 51511 kernels).
   
   The proposed approach is to use RTC (runtime compilation) in order to generate the needed kernels at runtime. This saves the ahead-of-time compilation time and binary size as well as the GPU memory utilization (since only the needed kernels are generated, not all combinations).
   
   This PR uses that approach to handle elementwise and broadcast kernels (as well as their backward), which constitute a big portion of the total number of kernels in MXNet.
   
   FYI @leezu @sxjscience @eric-haibin-lin 
   
   ## Checklist ##
   ### Essentials ###
   Please feel free to remove inapplicable items for your PR.
   - [ ] Changes are complete (i.e. I finished coding on this PR)
   - [x] All changes have test coverage
   - [ ] Code is well-documented: 
   - For new C++ functions in header files, their functionalities and arguments are documented. 
   - [x] To the best of my knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change
   
   ### Changes ###
    - RTC is now required for using CUDA in MXNet
    - Unary, binary, binary with scalar, binary broadcast ops and their backward counterparts were changed to use RTC 
   
   ## Comments ##
   - Things left to do:
   [ ] Test the performance impact of cache lookup for kernel code
   [ ] Convert `MixedUnaryBackward` functions
   [ ] Update PR description with the change in GPU memory utilization and binary size resulting from this PR
    - After this PR the next step would be to use the same approach for reduce kernels - this PR already contains a ground work for this as reduction was needed for backward of broadcast ops, but it does not apply that path to standalone reduction ops. Grepping for `reduce_kernel` in the symbols visible in libmxnet.so after application of this PR:
   ```
   cuobjdump -symbols -arch sm_70 /usr/local/lib/python3.6/dist-packages/mxnet/libmxnet.so | grep GLOBAL | grep reduce_kernel | wc -l
   ```
   gives 12057 entries. This would also help with reducing the amount of code duplication that this PR introduces (to maintain both RTC and non-RTC paths).
    


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] leezu commented on pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
leezu commented on pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#issuecomment-650359716


   > Another thing - it seems that the docker for jetson does not include NVRTC, who can change that?
   
   You can just edit the Dockerfile. But there might be a problem that NVidia fails to publish a NVRTC cross-compilation package. If so, you'll first need to get it published internally. (That's the case for TensorRT. But hopefully NVRTC is already available)


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#issuecomment-665150917


   @mxnet-bot run ci [windows-gpu]
   
   Flaky test test_gluon_dirichlet, tracked in #18809


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on a change in pull request #18622: Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r470740408



##########
File path: docs/python_docs/python/tutorials/extend/index.rst
##########
@@ -47,6 +47,12 @@ The following tutorials will help you learn how to customize MXNet.
       How to create new MXNet operators in MXNet's backend using C++.
       An example custom quadratic function op.
 
+   .. card::
+      :title: Using runtime compilation (RTC) to write CUDA kernels in MXNet
+      :link: https://mxnet.apache.org/api/faq/using_rtc

Review comment:
       Hmm, the toctree also has the full links - will `/api/faq/...` approach work there too?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on pull request #18622: Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#issuecomment-678646896


   Yes, I will look into it.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#issuecomment-654373793


   @leezu Thanks for listing the files - I am now looking into the contents of the right cross compilation package. I think you are right that everything should already be there and it is possibly just a package that was not installed in the Dockerfile itself, so I should be able to do this in the PR :-). 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#issuecomment-656793825


   @mxnet-bot run ci [windows-gpu]


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] DickJC123 commented on a change in pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
DickJC123 commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r457797096



##########
File path: src/common/cuda/rtc.cc
##########
@@ -0,0 +1,246 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "mxnet/base.h"
+
+#if MXNET_USE_CUDA
+
+#include <nvrtc.h>
+
+#include <mutex>
+#include <string>
+#include <fstream>
+#include <unordered_map>
+#include <vector>
+
+#include "rtc.h"
+#include "rtc/half-inl.h"
+#include "rtc/util-inl.h"
+#include "rtc/forward_functions-inl.h"
+#include "rtc/backward_functions-inl.h"
+#include "rtc/vectorization-inl.h"
+#include "rtc/special_functions-inl.h"
+#include "rtc/reducer-inl.h"
+#include "utils.h"
+
+
+namespace mxnet {
+namespace common {
+namespace cuda {
+namespace rtc {
+
+std::mutex lock;
+
+namespace util {
+
+std::string to_string(OpReqType req) {
+  switch (req) {
+    case kNullOp:
+      return "OpReqType::kNullOp";
+    case kWriteTo:
+    case kWriteInplace:
+      return "OpReqType::kWriteTo";
+    case kAddTo:
+      return "OpReqType::kAddTo";
+  }
+  LOG(FATAL) << "Unrecognized req.";
+  return "";
+}
+
+}  // namespace util
+
+namespace {
+
+// Obtain compilation log from the program.
+std::string GetCompileLog(nvrtcProgram program) {
+  size_t log_size_including_null;
+  NVRTC_CALL(nvrtcGetProgramLogSize(program, &log_size_including_null));
+  // For most std::string implementations, this is probably 1 char bigger than needed.  OK though.

Review comment:
       Actually, I see that the non-const version of data() is only available beginning with C++17.  What's the minimum C++ version that this code needs to work against?  Assuming it's C++11 and we go with &log[0] above, do you think that the array-size guarantee of size()+1 is there if the base data address is obtained via &log[0]?  While the Microsoft online documentation generally mirrors the cppreference link you posted, I couldn't find the text  "pointer to s[0] can be passed to functions that expect a pointer to the first element of a null-terminated (since C++11) CharT[] array" in anything from Microsoft, e.g. https://docs.microsoft.com/en-us/cpp/standard-library/basic-string-class?view=vs-2019




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] DickJC123 commented on a change in pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
DickJC123 commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r458244789



##########
File path: src/common/cuda/rtc.cc
##########
@@ -0,0 +1,246 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "mxnet/base.h"
+
+#if MXNET_USE_CUDA
+
+#include <nvrtc.h>
+
+#include <mutex>
+#include <string>
+#include <fstream>
+#include <unordered_map>
+#include <vector>
+
+#include "rtc.h"
+#include "rtc/half-inl.h"
+#include "rtc/util-inl.h"
+#include "rtc/forward_functions-inl.h"
+#include "rtc/backward_functions-inl.h"
+#include "rtc/vectorization-inl.h"
+#include "rtc/special_functions-inl.h"
+#include "rtc/reducer-inl.h"
+#include "utils.h"
+
+
+namespace mxnet {
+namespace common {
+namespace cuda {
+namespace rtc {
+
+std::mutex lock;
+
+namespace util {
+
+std::string to_string(OpReqType req) {
+  switch (req) {
+    case kNullOp:
+      return "OpReqType::kNullOp";
+    case kWriteTo:
+    case kWriteInplace:
+      return "OpReqType::kWriteTo";
+    case kAddTo:
+      return "OpReqType::kAddTo";
+  }
+  LOG(FATAL) << "Unrecognized req.";
+  return "";
+}
+
+}  // namespace util
+
+namespace {
+
+// Obtain compilation log from the program.
+std::string GetCompileLog(nvrtcProgram program) {
+  size_t log_size_including_null;
+  NVRTC_CALL(nvrtcGetProgramLogSize(program, &log_size_including_null));
+  // For most std::string implementations, this is probably 1 char bigger than needed.  OK though.

Review comment:
       I was assuming we wouldn't be using data() or c_str(), since they return a const pointer (data() has a non-const starting with C++17).  I was worried about a clever compiler that ensured the contiguous size()+1 layout and presence of the null byte lazily upon the user calling data() or c_str().  So assuming we access a non-const pointer to the beginning of the string via &log[0], do you feel Microsoft describes that the size()+1 layout exists at that point?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on a change in pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r457728745



##########
File path: src/common/cuda/rtc.cc
##########
@@ -0,0 +1,246 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "mxnet/base.h"
+
+#if MXNET_USE_CUDA
+
+#include <nvrtc.h>
+
+#include <mutex>
+#include <string>
+#include <fstream>
+#include <unordered_map>
+#include <vector>
+
+#include "rtc.h"
+#include "rtc/half-inl.h"
+#include "rtc/util-inl.h"
+#include "rtc/forward_functions-inl.h"
+#include "rtc/backward_functions-inl.h"
+#include "rtc/vectorization-inl.h"
+#include "rtc/special_functions-inl.h"
+#include "rtc/reducer-inl.h"
+#include "utils.h"
+
+
+namespace mxnet {
+namespace common {
+namespace cuda {
+namespace rtc {
+
+std::mutex lock;
+
+namespace util {
+
+std::string to_string(OpReqType req) {
+  switch (req) {
+    case kNullOp:
+      return "OpReqType::kNullOp";
+    case kWriteTo:
+    case kWriteInplace:
+      return "OpReqType::kWriteTo";
+    case kAddTo:
+      return "OpReqType::kAddTo";
+  }
+  LOG(FATAL) << "Unrecognized req.";
+  return "";
+}
+
+}  // namespace util
+
+namespace {
+
+// Obtain compilation log from the program.
+std::string GetCompileLog(nvrtcProgram program) {
+  size_t log_size_including_null;
+  NVRTC_CALL(nvrtcGetProgramLogSize(program, &log_size_including_null));
+  // For most std::string implementations, this is probably 1 char bigger than needed.  OK though.
+  std::string log(log_size_including_null, '\0');
+  NVRTC_CALL(nvrtcGetProgramLog(program, &log[0]));
+  // Make sure the string reflects the true size (so minus the null terminator).
+  log.resize(log_size_including_null - 1);
+  return log;
+}
+
+// Obtain compilation result (ptx assembly) from the program.
+std::string GetPtx(nvrtcProgram program) {
+  size_t ptx_size_including_null;
+  NVRTC_CALL(nvrtcGetPTXSize(program, &ptx_size_including_null));
+  // For most std::string implementations, this is probably 1 char bigger than needed.  OK though.
+  std::string ptx(ptx_size_including_null, '\0');
+  NVRTC_CALL(nvrtcGetPTX(program, &ptx[0]));
+  // Make sure the string reflects the true size (so minus the null terminator).
+  ptx.resize(ptx_size_including_null - 1);
+  return ptx;
+}
+
+}  // namespace
+
+CUfunction get_function(const std::string &parameters,
+                        const std::string &kernel_name,
+                        const std::string &code,
+                        int dev_id) {
+  constexpr int CACHESIZE_WARN_THRESHOLD = 10000;
+  std::lock_guard<std::mutex> l(lock);
+  // Local class for value type of compile cache
+  struct KernelInfo {
+    std::string mangled_name;
+    std::string ptx;
+    std::vector<CUfunction> functions;
+  };
+  // Maps from the kernel name and parameters to the ptx and jit-compiled CUfunctions.
+  using KernelCache = std::unordered_map<std::string, KernelInfo>;
+  // Per-gpu-architecture compiled kernel cache with jit-compiled function for each device context
+  static std::unordered_map<int32_t, KernelCache> compiled_kernels;
+  int sm_arch = SMArch(dev_id);
+  // make null map as needed
+  KernelCache& compiled_kernels_this_arch = compiled_kernels[sm_arch];
+  // make KernelInfo as needed
+  KernelInfo& kinfo = compiled_kernels_this_arch[parameters + kernel_name];
+  if (kinfo.ptx.size() == 0) {
+    // It's the first time we've seen this kernel, so we need to generate the ptx and mangled_name.
+    static std::string common_header =
+        std::string(fp16_support_string) + "\n" +
+        type_support_string + "\n" +
+        util_string + "\n" +
+        special_functions_definitions + '\n' +
+        function_definitions_util + "\n" +
+        function_definitions_binary + "\n" +
+        function_definitions_unary + "\n" +
+        backward_function_definitions + "\n" +
+        vectorization_support_string + "\n" +
+        reducer + "\n";
+    std::string code_with_header = common_header + parameters + code;
+    // If verbose mode, output kernel source, though not including the common header
+    if (dmlc::GetEnv("MXNET_RTC_VERBOSE", false)) {
+      LOG(INFO) << "\n" << std::string(80, '-') << "\n" << (parameters + code);
+    }
+    if (compiled_kernels_this_arch.size() == CACHESIZE_WARN_THRESHOLD + 1 &&
+        dmlc::GetEnv("MXNET_RTC_SIZE_WARNING", true)) {
+      LOG(WARNING) << "The number of different compiled kernels exceeds "
+                   << CACHESIZE_WARN_THRESHOLD
+                   << ".  Set MXNET_RTC_SIZE_WARNING=0 to quiet this warning.";
+    }
+    nvrtcProgram program;
+    NVRTC_CALL(nvrtcCreateProgram(&program,                                  // prog
+                                  &code_with_header[0],                      // buffer
+                                  (kernel_name + "_kernel.cu").c_str(),      // name
+                                  0,                                         // num headers
+                                  nullptr,                                   // headers
+                                  nullptr));                                 // include names
+
+    std::string gpu_arch_arg = "--gpu-architecture=compute_" + std::to_string(sm_arch);
+    const char *opts[] = {gpu_arch_arg.c_str(),
+#if NDEBUG == 0
+                          "-G",
+#endif
+                          "--std=c++11"};

Review comment:
       :+1:




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#issuecomment-654316485


   @ChaiBapchya The Jetson CI pipeline fails with not being able to find NVRTC - I confirmed it is part of jetpack, so I guess it is not included in the package of libs you have in S3. Can you update it? (And yes, I'm aware of issue #18637).


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #18622: Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#issuecomment-671148261


   Jenkins CI successfully triggered : [unix-cpu]


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on pull request #18622: Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#issuecomment-671148243


   @mxnet-bot run ci [unix-cpu]


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#issuecomment-649858077


   Hey @ptrendx , Thanks for submitting the PR 
   All tests are already queued to run once. If tests fail, you can trigger one or more tests again with the following commands: 
   - To trigger all jobs: @mxnet-bot run ci [all] 
   - To trigger specific jobs: @mxnet-bot run ci [job1, job2] 
   *** 
   **CI supported jobs**: [unix-cpu, windows-gpu, centos-cpu, unix-gpu, windows-cpu, edge, miscellaneous, website, centos-gpu, sanity, clang]
   *** 
   _Note_: 
    Only following 3 categories can trigger CI :PR Author, MXNet Committer, Jenkins Admin. 
   All CI tests must pass before the PR can be merged. 
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#issuecomment-651291330


   Hi @ChaiBapchya could you tell me whether there is any difference in hw/sw of centos-gpu runners compared to unix-gpu runners? I see some failures on centos-gpu that do not happen on unix-gpu.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] leezu commented on a change in pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
leezu commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r457573754



##########
File path: ci/docker/Dockerfile.build.jetson
##########
@@ -90,6 +90,9 @@ RUN wget https://repo.download.nvidia.com/jetson/x86_64/pool/r32.4/c/cuda/cuda-c
 # while previously it used to store it at /usr/local/cuda/targets/aarch64-linux/lib/stubs
 RUN ln -s /usr/lib/aarch64-linux-gnu/libcublas.so /usr/local/cuda/targets/aarch64-linux/lib/stubs/libcublas.so
 
+# Need the stub for libcuda.so in a place where host linker can find it to link the unit tests
+RUN ln -s /usr/local/cuda/targets/aarch64-linux/lib/stubs/libcuda.so /usr/lib/aarch64-linux-gnu/libcuda.so

Review comment:
       Do you know why `/usr/local/cuda/targets/aarch64-linux/lib/stubs/libcuda.so` is not detected by cmake? It shouldn't be necessary to create this symlink (it isn't necessary in the non-cross-compile setting). Have you reported a bug in the cmake repository? Also, what's the plan for https://github.com/apache/incubator-mxnet/issues/17858 ?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#issuecomment-649884365


   Yeah, we will need to sort it out before the release - I actually thought that if we manage to get everything via RTC (which seems daunting though), we could actually dynamically load both libcuda and libnvrtc and have a single build that supports everything instead of mxnet-cu*. That said, RTC for everything is a big task and I would definitely need help from community if we were to pull it off.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] leezu commented on a change in pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
leezu commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r457769003



##########
File path: src/common/cuda/rtc.cc
##########
@@ -0,0 +1,246 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "mxnet/base.h"
+
+#if MXNET_USE_CUDA
+
+#include <nvrtc.h>
+
+#include <mutex>
+#include <string>
+#include <fstream>
+#include <unordered_map>
+#include <vector>
+
+#include "rtc.h"
+#include "rtc/half-inl.h"
+#include "rtc/util-inl.h"
+#include "rtc/forward_functions-inl.h"
+#include "rtc/backward_functions-inl.h"
+#include "rtc/vectorization-inl.h"
+#include "rtc/special_functions-inl.h"
+#include "rtc/reducer-inl.h"
+#include "utils.h"
+
+
+namespace mxnet {
+namespace common {
+namespace cuda {
+namespace rtc {
+
+std::mutex lock;
+
+namespace util {
+
+std::string to_string(OpReqType req) {
+  switch (req) {
+    case kNullOp:
+      return "OpReqType::kNullOp";
+    case kWriteTo:
+    case kWriteInplace:
+      return "OpReqType::kWriteTo";
+    case kAddTo:
+      return "OpReqType::kAddTo";
+  }
+  LOG(FATAL) << "Unrecognized req.";
+  return "";
+}
+
+}  // namespace util
+
+namespace {
+
+// Obtain compilation log from the program.
+std::string GetCompileLog(nvrtcProgram program) {
+  size_t log_size_including_null;
+  NVRTC_CALL(nvrtcGetProgramLogSize(program, &log_size_including_null));
+  // For most std::string implementations, this is probably 1 char bigger than needed.  OK though.

Review comment:
       Thank you for clarifying @DickJC123.
   
   > I think most implementations of std::string will add 1 to the size you give at string construction time, because they want an efficient implementation of string::c_str(). So it would probably work, but why risk it?
   
   As of C++11, the standard guarantees that "a pointer to s[0] can be passed to functions that expect a pointer to the first element of a null-terminated CharT[] array" according to https://en.cppreference.com/w/cpp/string/basic_string. Ie the pointer returned by `s.c_str()` must be the same as as the pointer to `s[0]`. So there should be no risk in allocating the string of true size and avoid the extra resize as long as nvrtcGetProgramLog doesn't replace the null-byte.

##########
File path: src/common/cuda/rtc.cc
##########
@@ -0,0 +1,246 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "mxnet/base.h"
+
+#if MXNET_USE_CUDA
+
+#include <nvrtc.h>
+
+#include <mutex>
+#include <string>
+#include <fstream>
+#include <unordered_map>
+#include <vector>
+
+#include "rtc.h"
+#include "rtc/half-inl.h"
+#include "rtc/util-inl.h"
+#include "rtc/forward_functions-inl.h"
+#include "rtc/backward_functions-inl.h"
+#include "rtc/vectorization-inl.h"
+#include "rtc/special_functions-inl.h"
+#include "rtc/reducer-inl.h"
+#include "utils.h"
+
+
+namespace mxnet {
+namespace common {
+namespace cuda {
+namespace rtc {
+
+std::mutex lock;
+
+namespace util {
+
+std::string to_string(OpReqType req) {
+  switch (req) {
+    case kNullOp:
+      return "OpReqType::kNullOp";
+    case kWriteTo:
+    case kWriteInplace:
+      return "OpReqType::kWriteTo";
+    case kAddTo:
+      return "OpReqType::kAddTo";
+  }
+  LOG(FATAL) << "Unrecognized req.";
+  return "";
+}
+
+}  // namespace util
+
+namespace {
+
+// Obtain compilation log from the program.
+std::string GetCompileLog(nvrtcProgram program) {
+  size_t log_size_including_null;
+  NVRTC_CALL(nvrtcGetProgramLogSize(program, &log_size_including_null));
+  // For most std::string implementations, this is probably 1 char bigger than needed.  OK though.

Review comment:
       Thank you for clarifying @DickJC123.
   
   > I think most implementations of std::string will add 1 to the size you give at string construction time, because they want an efficient implementation of string::c_str(). So it would probably work, but why risk it?
   
   As of C++11, the standard guarantees that "a pointer to s[0] can be passed to functions that expect a pointer to the first element of a null-terminated CharT[] array" according to https://en.cppreference.com/w/cpp/string/basic_string. Ie the pointer returned by `s.c_str()` must be the same as as the pointer to `s[0]`. So there should be no risk in allocating the string of true size and avoid the extra resize as long as nvrtcGetProgramLog doesn't replace the null-byte?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on a change in pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r457724415



##########
File path: src/operator/numpy/np_elemwise_broadcast_op_extended.cc
##########
@@ -201,16 +201,12 @@ MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR(_npi_copysign_scalar)
 
 MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR(_npi_rcopysign_scalar)
 .set_attr<FCompute>("FCompute<cpu>", BinaryScalarOp::Compute<cpu, mshadow_op::rcopysign>)
-.set_attr<nnvm::FGradient>("FGradient", ElemwiseGradUseIn{"_backward_npi_rcopysign_scalar"});
+.set_attr<nnvm::FGradient>("FGradient", MakeZeroGradNodes);

Review comment:
       Because `rcopysign_grad` is 0 :-): https://github.com/apache/incubator-mxnet/blob/master/src/operator/mshadow_op.h#L777
   
   I noticed this when adding the RTC version, so figured instead of adding a custom code for zero it is better to reuse the existing mechanism to handle the case when gradients are 0.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] leezu commented on a change in pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
leezu commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r458297191



##########
File path: src/common/cuda/rtc.cc
##########
@@ -0,0 +1,246 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "mxnet/base.h"
+
+#if MXNET_USE_CUDA
+
+#include <nvrtc.h>
+
+#include <mutex>
+#include <string>
+#include <fstream>
+#include <unordered_map>
+#include <vector>
+
+#include "rtc.h"
+#include "rtc/half-inl.h"
+#include "rtc/util-inl.h"
+#include "rtc/forward_functions-inl.h"
+#include "rtc/backward_functions-inl.h"
+#include "rtc/vectorization-inl.h"
+#include "rtc/special_functions-inl.h"
+#include "rtc/reducer-inl.h"
+#include "utils.h"
+
+
+namespace mxnet {
+namespace common {
+namespace cuda {
+namespace rtc {
+
+std::mutex lock;
+
+namespace util {
+
+std::string to_string(OpReqType req) {
+  switch (req) {
+    case kNullOp:
+      return "OpReqType::kNullOp";
+    case kWriteTo:
+    case kWriteInplace:
+      return "OpReqType::kWriteTo";
+    case kAddTo:
+      return "OpReqType::kAddTo";
+  }
+  LOG(FATAL) << "Unrecognized req.";
+  return "";
+}
+
+}  // namespace util
+
+namespace {
+
+// Obtain compilation log from the program.
+std::string GetCompileLog(nvrtcProgram program) {
+  size_t log_size_including_null;
+  NVRTC_CALL(nvrtcGetProgramLogSize(program, &log_size_including_null));
+  // For most std::string implementations, this is probably 1 char bigger than needed.  OK though.

Review comment:
       We require C++17 for all CPU code (which should include the RTC "managamenet" code):
   
   https://github.com/apache/incubator-mxnet/blob/6bb3d724189e1d5727fc7b2b41cab3863294ff99/CMakeLists.txt#L9-L12
   
   though the CUDA code is compiled with C++14 due to lack of C++17 support in Cuda 10
   
   https://github.com/apache/incubator-mxnet/blob/6bb3d724189e1d5727fc7b2b41cab3863294ff99/CMakeLists.txt#L118-L120




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] szha commented on a change in pull request #18622: Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
szha commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r470423077



##########
File path: src/common/cuda/rtc/util-inl.h
##########
@@ -0,0 +1,380 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef MXNET_COMMON_CUDA_RTC_UTIL_INL_H_
+#define MXNET_COMMON_CUDA_RTC_UTIL_INL_H_
+
+#include <mxnet/base.h>
+
+#if MXNET_USE_CUDA
+
+namespace mxnet {
+namespace common {
+namespace cuda {
+namespace rtc {
+
+const char type_support_string[] = R"code(
+using float32 = float;
+using float64 = double;
+using float16 = half;
+using uint8 = unsigned char;
+using int8 = char;
+using int32 = int;
+using int64 = long long;

Review comment:
       I see. How is the type size determined?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] DickJC123 commented on a change in pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
DickJC123 commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r457754438



##########
File path: src/common/cuda/rtc.cc
##########
@@ -0,0 +1,246 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "mxnet/base.h"
+
+#if MXNET_USE_CUDA
+
+#include <nvrtc.h>
+
+#include <mutex>
+#include <string>
+#include <fstream>
+#include <unordered_map>
+#include <vector>
+
+#include "rtc.h"
+#include "rtc/half-inl.h"
+#include "rtc/util-inl.h"
+#include "rtc/forward_functions-inl.h"
+#include "rtc/backward_functions-inl.h"
+#include "rtc/vectorization-inl.h"
+#include "rtc/special_functions-inl.h"
+#include "rtc/reducer-inl.h"
+#include "utils.h"
+
+
+namespace mxnet {
+namespace common {
+namespace cuda {
+namespace rtc {
+
+std::mutex lock;
+
+namespace util {
+
+std::string to_string(OpReqType req) {
+  switch (req) {
+    case kNullOp:
+      return "OpReqType::kNullOp";
+    case kWriteTo:
+    case kWriteInplace:
+      return "OpReqType::kWriteTo";
+    case kAddTo:
+      return "OpReqType::kAddTo";
+  }
+  LOG(FATAL) << "Unrecognized req.";
+  return "";
+}
+
+}  // namespace util
+
+namespace {
+
+// Obtain compilation log from the program.
+std::string GetCompileLog(nvrtcProgram program) {
+  size_t log_size_including_null;
+  NVRTC_CALL(nvrtcGetProgramLogSize(program, &log_size_including_null));
+  // For most std::string implementations, this is probably 1 char bigger than needed.  OK though.

Review comment:
       I wrote the code awhile back, but I think I see the logic behind it.  Forgive me, but I prefer to think of it by way of a concrete example:
   
   Let's say the compile log had 100 characters. The nvrtcGetProgramLogSize() call would report a size of 101 and the nvrtcGetProgramLog() call would copy 101 characters to the pointer address passed to it.  The 101 characters are the 100 characters of the log plus a null byte.  This approach is targeting a C interface- you're expected to malloc an array of 101 bytes (the length reported to you) and all is well.
   
   Here though, we want the program log ultimately to look like std::string of 100 characters.  However, do we want to allocate the string of size 100, then hope we can copy 101 bytes into it?  I think most implementations of std::string will add 1 to the size you give at string construction time, because they want an efficient implementation of string::c_str().  So it would probably work, but why risk it?  Basically, we allocate the string with length 101, let nvrtcGetProgramLog() copy the 101 bytes into it, then resize the string to length 100 so we don't have the null character messing up any print or other string manipulations we do down the road.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#issuecomment-656793865


   Jenkins CI successfully triggered : [windows-gpu]


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ZiyueHuang commented on pull request #18622: Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ZiyueHuang commented on pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#issuecomment-678613328


   After this PR, the training of Electra Model in gluon-nlp will raise error below
   ```
   mxnet.base.MXNetError: Traceback (most recent call last):
     File "/home/ubuntu/mxnet/src/common/cuda/rtc.cc", line 163
   MXNetError: Check failed: compileResult == NVRTC_SUCCESS (6 vs. 0) : NVRTC Compilation failed.
   The generated code was stored in mxnet_rtc_debug_code.log
   binary_scalar_kernel_kernel.cu(1118): error: more than one instance of overloaded function "isnan" matches the argument list:
               function "isnan(float)"
               function "isnan(double)"
               function "isnan(long double)"
               argument types are: (const InputType0)
             detected during instantiation of "type_util::mixed_type<DType, DType2, void>::type op::min(DType, DType2) [with DType=InputType0, DType2=InputType0]"
   (2285): here
   ```
   
   Setting `MXNET_RTC_VERBOSE =1` will get the code for `binary_scalar_kernel`
   ```
   using InputType0 = float32;
   using OutputType0 = float32;
   const bool aligned = true;
   const int nvec = 4;
   const OpReqType req = OpReqType::kWriteTo;
   #define OP op::div
   
   
   struct binary_scalar_kernel_params {
     const void *inputs[2];
     void *outputs[1];
     double scalar;
   };
   
   __launch_bounds__(kRTCMaxThreadsPerBlock)
   __global__ void binary_scalar_kernel(const binary_scalar_kernel_params params,
                                        const index_t lead_dim,
                                        const index_t other_dim,
                                        const index_t N,
                                        const index_t num_aligned_elements) {
     using namespace vector;
     VectorizedLoader<InputType0, nvec, aligned> loader(
       reinterpret_cast<const InputType0*>(params.inputs[0]), N);
     VectorizedStorer<OutputType0, nvec, aligned> storer(
       reinterpret_cast<OutputType0*>(params.outputs[0]), N);
   
     using IType = AccType<InputType0>;
     using OType = AccType<OutputType0>;
   
     const index_t M = num_aligned_elements;
   
     for (index_t tid = blockIdx.x * blockDim.x + threadIdx.x;
          tid < M;
          tid += gridDim.x * blockDim.x) {
       loader.load(tid, N);
       if (req == OpReqType::kAddTo) {
         storer.load(tid, N);
       }
   #pragma unroll
       for (int i = 0; i < nvec; ++i) {
         const auto input = IType::from(loader.separate()[i]);
         // enables returning different type
         const auto temp = OP(input,
                              static_cast<typename type_util::mixed_type<typename IType::type,
                                                                         typename OType::type>::type>
                                (params.scalar));
   
         if (req == OpReqType::kAddTo) {
           // temp2 may have a wider type than either temp
           // or OType
           const auto temp2 = op::add(temp, OType::from(storer.separate()[i]));
           storer.separate()[i] = OType::to(temp2);
         } else {
           storer.separate()[i] = OType::to(temp);
         }
       }
       storer.store(tid, N);
     }
   }
   
   ```
   
   @ptrendx Could you please take a look?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ChaiBapchya commented on pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ChaiBapchya commented on pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#issuecomment-651446932


   Based on the existing CI infra setup, both centos-gpu & unix-gpu run on the same AMI
   Same AMI translates essentially to same HW/SW.
   However, after the instance is created, it runs the CI on a docker file. That dockerfile setup is different from unix & centos
   
   Centos BUILD: https://github.com/apache/incubator-mxnet/blob/master/ci/docker/Dockerfile.build.centos7
   Centos Test: https://github.com/apache/incubator-mxnet/blob/master/ci/docker/Dockerfile.publish.test.centos7
   
   The variables used in these dockerfiles are defined in https://github.com/apache/incubator-mxnet/blob/master/ci/docker/docker-compose.yml
   
   For e.g. 
   In your case: http://jenkins.mxnet-ci.amazon-ml.com/blue/organizations/jenkins/mxnet-validation%2Fcentos-gpu/detail/PR-18622/9/pipeline
   Fails at 
   ```
   ci/build.py --docker-registry mxnetci --nvidiadocker --platform centos7_gpu_cu92 --docker-build-retries 3 --shm-size 500m /work/runtime_functions.sh unittest_centos7_gpu
   ```
   
   Thus the platform `centos7_gpu_cu92` defined here
   
   https://github.com/apache/incubator-mxnet/blob/master/ci/docker/docker-compose.yml#L44-L53
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] leezu commented on a change in pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
leezu commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r457594285



##########
File path: ci/docker/Dockerfile.build.jetson
##########
@@ -90,6 +90,9 @@ RUN wget https://repo.download.nvidia.com/jetson/x86_64/pool/r32.4/c/cuda/cuda-c
 # while previously it used to store it at /usr/local/cuda/targets/aarch64-linux/lib/stubs
 RUN ln -s /usr/lib/aarch64-linux-gnu/libcublas.so /usr/local/cuda/targets/aarch64-linux/lib/stubs/libcublas.so
 
+# Need the stub for libcuda.so in a place where host linker can find it to link the unit tests
+RUN ln -s /usr/local/cuda/targets/aarch64-linux/lib/stubs/libcuda.so /usr/lib/aarch64-linux-gnu/libcuda.so

Review comment:
       `mxnet_unit_tests` is a cmake target that depends on the `libmxnet` target. The libraries detected when compiling `libmxnet` will also be propagated to `mxnet_unit_tests`. I think the problem is that you just added the `cuda` as dependency, instead of the correct `CUDA::cuda_driver` found by https://gitlab.kitware.com/cmake/cmake/-/blob/master/Modules/FindCUDAToolkit.cmake.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on a change in pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r457622484



##########
File path: ci/docker/Dockerfile.build.jetson
##########
@@ -90,6 +90,9 @@ RUN wget https://repo.download.nvidia.com/jetson/x86_64/pool/r32.4/c/cuda/cuda-c
 # while previously it used to store it at /usr/local/cuda/targets/aarch64-linux/lib/stubs
 RUN ln -s /usr/lib/aarch64-linux-gnu/libcublas.so /usr/local/cuda/targets/aarch64-linux/lib/stubs/libcublas.so
 
+# Need the stub for libcuda.so in a place where host linker can find it to link the unit tests
+RUN ln -s /usr/local/cuda/targets/aarch64-linux/lib/stubs/libcuda.so /usr/lib/aarch64-linux-gnu/libcuda.so

Review comment:
       Ok, let me try changing it.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#issuecomment-652530647


   @mxnet-bot run ci [windows-gpu, unix-gpu, miscellaneous, website, centos-gpu, sanity, clang]


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on a change in pull request #18622: Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r470857813



##########
File path: docs/python_docs/python/tutorials/extend/index.rst
##########
@@ -47,6 +47,12 @@ The following tutorials will help you learn how to customize MXNet.
       How to create new MXNet operators in MXNet's backend using C++.
       An example custom quadratic function op.
 
+   .. card::
+      :title: Using runtime compilation (RTC) to write CUDA kernels in MXNet
+      :link: https://mxnet.apache.org/api/faq/using_rtc

Review comment:
       Nice :-). I will push the changes to address your other comments then and will get back to the website part once your PR is merged.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#issuecomment-656326226


   I looked at the performance impact of RTC and it adds ~2us of CPU time to the launch, mostly due to string manipulation.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] leezu commented on pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
leezu commented on pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#issuecomment-650325459


   > Also, I thought that you made the compilation use C++17 (so I use `if constexpr`), but now I see that the CUDA part is compiled with C++14 (and fails). What is the reason of that?
   
   The reason is that CUDA does not support C++17 prior to CUDA11. We can consider requiring CUDA11 for MXNet 2


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] DickJC123 commented on a change in pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
DickJC123 commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r458310059



##########
File path: src/common/cuda/rtc.cc
##########
@@ -0,0 +1,246 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "mxnet/base.h"
+
+#if MXNET_USE_CUDA
+
+#include <nvrtc.h>
+
+#include <mutex>
+#include <string>
+#include <fstream>
+#include <unordered_map>
+#include <vector>
+
+#include "rtc.h"
+#include "rtc/half-inl.h"
+#include "rtc/util-inl.h"
+#include "rtc/forward_functions-inl.h"
+#include "rtc/backward_functions-inl.h"
+#include "rtc/vectorization-inl.h"
+#include "rtc/special_functions-inl.h"
+#include "rtc/reducer-inl.h"
+#include "utils.h"
+
+
+namespace mxnet {
+namespace common {
+namespace cuda {
+namespace rtc {
+
+std::mutex lock;
+
+namespace util {
+
+std::string to_string(OpReqType req) {
+  switch (req) {
+    case kNullOp:
+      return "OpReqType::kNullOp";
+    case kWriteTo:
+    case kWriteInplace:
+      return "OpReqType::kWriteTo";
+    case kAddTo:
+      return "OpReqType::kAddTo";
+  }
+  LOG(FATAL) << "Unrecognized req.";
+  return "";
+}
+
+}  // namespace util
+
+namespace {
+
+// Obtain compilation log from the program.
+std::string GetCompileLog(nvrtcProgram program) {
+  size_t log_size_including_null;
+  NVRTC_CALL(nvrtcGetProgramLogSize(program, &log_size_including_null));
+  // For most std::string implementations, this is probably 1 char bigger than needed.  OK though.

Review comment:
       You might be surprised to hear that I'm actually ambivalent which way we go here.  The way I see it, the two approaches are:
   
   1. Existing approach- works, more conservative coding style, has unneeded resize() (2 lines)
   2. Proposed approach- simpler, small bit faster due to eliminating resize(), closer to 'bleeding edge' of C++11 standard
   
   I propose we go with approach 2, without the resize(), as suggested by @leezu.  However, let's leave in the comment that I included in my code snippet above.  If the RTC ever starts segfaulting, and I'm pulled in to debug it, the comment would be a sufficient reminder to me to revert to the former approach to eliminate compiler standard non-compliance as a possible cause.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#issuecomment-650340559


   Yeah, I wasn't aware of that. I decided to change the `if constexpr` to `#ifdef`s for now as the gpu portion is still compiled with nvcc.
   
   Another thing - it seems that the docker for jetson does not include NVRTC, who can change that?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#issuecomment-665150949


   Jenkins CI successfully triggered : [windows-gpu]


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] leezu commented on pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
leezu commented on pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#issuecomment-649874901


   Thank you @ptrendx! As this makes nvrtc feature mandatory, it may be necessary to first/prior to next release also fix https://github.com/apache/incubator-mxnet/issues/17858? It seems that there are a number of users that try to open GPU builds on machines without libcuda.so and this is broken since 1.6 due to https://github.com/apache/incubator-mxnet/issues/17858 (but currently there is the workaround of disabling nvrtc)


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#issuecomment-649884766


   Also, I thought that you made the compilation use C++17 (so I use `if constexpr`), but now I see that the CUDA part is compiled with C++14 (and fails). What is the reason of that?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] leezu commented on a change in pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
leezu commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r457718521



##########
File path: src/common/cuda/rtc.cc
##########
@@ -0,0 +1,246 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "mxnet/base.h"
+
+#if MXNET_USE_CUDA
+
+#include <nvrtc.h>
+
+#include <mutex>
+#include <string>
+#include <fstream>
+#include <unordered_map>
+#include <vector>
+
+#include "rtc.h"
+#include "rtc/half-inl.h"
+#include "rtc/util-inl.h"
+#include "rtc/forward_functions-inl.h"
+#include "rtc/backward_functions-inl.h"
+#include "rtc/vectorization-inl.h"
+#include "rtc/special_functions-inl.h"
+#include "rtc/reducer-inl.h"
+#include "utils.h"
+
+
+namespace mxnet {
+namespace common {
+namespace cuda {
+namespace rtc {
+
+std::mutex lock;
+
+namespace util {
+
+std::string to_string(OpReqType req) {
+  switch (req) {
+    case kNullOp:
+      return "OpReqType::kNullOp";
+    case kWriteTo:
+    case kWriteInplace:
+      return "OpReqType::kWriteTo";
+    case kAddTo:
+      return "OpReqType::kAddTo";
+  }
+  LOG(FATAL) << "Unrecognized req.";
+  return "";
+}
+
+}  // namespace util
+
+namespace {
+
+// Obtain compilation log from the program.
+std::string GetCompileLog(nvrtcProgram program) {
+  size_t log_size_including_null;
+  NVRTC_CALL(nvrtcGetProgramLogSize(program, &log_size_including_null));
+  // For most std::string implementations, this is probably 1 char bigger than needed.  OK though.

Review comment:
       Why is it needed?
   
   "The elements of a basic_string are stored contiguously, that is, for a basic_string s, &*(s.begin() + n) == &*s.begin() + n for any n in [0, s.size()), or, equivalently, a pointer to s[0] can be passed to functions that expect a pointer to the first element of a null-terminated (since C++11)CharT[] array."
   
   https://en.cppreference.com/w/cpp/string/basic_string

##########
File path: src/common/cuda/rtc.cc
##########
@@ -0,0 +1,246 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "mxnet/base.h"
+
+#if MXNET_USE_CUDA
+
+#include <nvrtc.h>
+
+#include <mutex>
+#include <string>
+#include <fstream>
+#include <unordered_map>
+#include <vector>
+
+#include "rtc.h"
+#include "rtc/half-inl.h"
+#include "rtc/util-inl.h"
+#include "rtc/forward_functions-inl.h"
+#include "rtc/backward_functions-inl.h"
+#include "rtc/vectorization-inl.h"
+#include "rtc/special_functions-inl.h"
+#include "rtc/reducer-inl.h"
+#include "utils.h"
+
+
+namespace mxnet {
+namespace common {
+namespace cuda {
+namespace rtc {
+
+std::mutex lock;
+
+namespace util {
+
+std::string to_string(OpReqType req) {
+  switch (req) {
+    case kNullOp:
+      return "OpReqType::kNullOp";
+    case kWriteTo:
+    case kWriteInplace:
+      return "OpReqType::kWriteTo";
+    case kAddTo:
+      return "OpReqType::kAddTo";
+  }
+  LOG(FATAL) << "Unrecognized req.";
+  return "";
+}
+
+}  // namespace util
+
+namespace {
+
+// Obtain compilation log from the program.
+std::string GetCompileLog(nvrtcProgram program) {
+  size_t log_size_including_null;
+  NVRTC_CALL(nvrtcGetProgramLogSize(program, &log_size_including_null));
+  // For most std::string implementations, this is probably 1 char bigger than needed.  OK though.
+  std::string log(log_size_including_null, '\0');
+  NVRTC_CALL(nvrtcGetProgramLog(program, &log[0]));
+  // Make sure the string reflects the true size (so minus the null terminator).
+  log.resize(log_size_including_null - 1);
+  return log;
+}
+
+// Obtain compilation result (ptx assembly) from the program.
+std::string GetPtx(nvrtcProgram program) {
+  size_t ptx_size_including_null;
+  NVRTC_CALL(nvrtcGetPTXSize(program, &ptx_size_including_null));
+  // For most std::string implementations, this is probably 1 char bigger than needed.  OK though.
+  std::string ptx(ptx_size_including_null, '\0');
+  NVRTC_CALL(nvrtcGetPTX(program, &ptx[0]));
+  // Make sure the string reflects the true size (so minus the null terminator).
+  ptx.resize(ptx_size_including_null - 1);
+  return ptx;
+}
+
+}  // namespace
+
+CUfunction get_function(const std::string &parameters,
+                        const std::string &kernel_name,
+                        const std::string &code,
+                        int dev_id) {
+  constexpr int CACHESIZE_WARN_THRESHOLD = 10000;
+  std::lock_guard<std::mutex> l(lock);
+  // Local class for value type of compile cache
+  struct KernelInfo {
+    std::string mangled_name;
+    std::string ptx;
+    std::vector<CUfunction> functions;
+  };
+  // Maps from the kernel name and parameters to the ptx and jit-compiled CUfunctions.
+  using KernelCache = std::unordered_map<std::string, KernelInfo>;
+  // Per-gpu-architecture compiled kernel cache with jit-compiled function for each device context
+  static std::unordered_map<int32_t, KernelCache> compiled_kernels;
+  int sm_arch = SMArch(dev_id);
+  // make null map as needed
+  KernelCache& compiled_kernels_this_arch = compiled_kernels[sm_arch];
+  // make KernelInfo as needed
+  KernelInfo& kinfo = compiled_kernels_this_arch[parameters + kernel_name];
+  if (kinfo.ptx.size() == 0) {
+    // It's the first time we've seen this kernel, so we need to generate the ptx and mangled_name.
+    static std::string common_header =
+        std::string(fp16_support_string) + "\n" +
+        type_support_string + "\n" +
+        util_string + "\n" +
+        special_functions_definitions + '\n' +
+        function_definitions_util + "\n" +
+        function_definitions_binary + "\n" +
+        function_definitions_unary + "\n" +
+        backward_function_definitions + "\n" +
+        vectorization_support_string + "\n" +
+        reducer + "\n";
+    std::string code_with_header = common_header + parameters + code;
+    // If verbose mode, output kernel source, though not including the common header
+    if (dmlc::GetEnv("MXNET_RTC_VERBOSE", false)) {
+      LOG(INFO) << "\n" << std::string(80, '-') << "\n" << (parameters + code);
+    }
+    if (compiled_kernels_this_arch.size() == CACHESIZE_WARN_THRESHOLD + 1 &&
+        dmlc::GetEnv("MXNET_RTC_SIZE_WARNING", true)) {
+      LOG(WARNING) << "The number of different compiled kernels exceeds "
+                   << CACHESIZE_WARN_THRESHOLD
+                   << ".  Set MXNET_RTC_SIZE_WARNING=0 to quiet this warning.";
+    }
+    nvrtcProgram program;
+    NVRTC_CALL(nvrtcCreateProgram(&program,                                  // prog
+                                  &code_with_header[0],                      // buffer
+                                  (kernel_name + "_kernel.cu").c_str(),      // name
+                                  0,                                         // num headers
+                                  nullptr,                                   // headers
+                                  nullptr));                                 // include names
+
+    std::string gpu_arch_arg = "--gpu-architecture=compute_" + std::to_string(sm_arch);
+    const char *opts[] = {gpu_arch_arg.c_str(),
+#if NDEBUG == 0
+                          "-G",
+#endif
+                          "--std=c++11"};

Review comment:
       `c++14`?

##########
File path: src/operator/numpy/np_elemwise_broadcast_op_extended.cc
##########
@@ -201,16 +201,12 @@ MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR(_npi_copysign_scalar)
 
 MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR(_npi_rcopysign_scalar)
 .set_attr<FCompute>("FCompute<cpu>", BinaryScalarOp::Compute<cpu, mshadow_op::rcopysign>)
-.set_attr<nnvm::FGradient>("FGradient", ElemwiseGradUseIn{"_backward_npi_rcopysign_scalar"});
+.set_attr<nnvm::FGradient>("FGradient", MakeZeroGradNodes);

Review comment:
       Why change the grad nodes?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] leezu commented on a change in pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
leezu commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r457594478



##########
File path: ci/docker/Dockerfile.build.jetson
##########
@@ -90,6 +90,9 @@ RUN wget https://repo.download.nvidia.com/jetson/x86_64/pool/r32.4/c/cuda/cuda-c
 # while previously it used to store it at /usr/local/cuda/targets/aarch64-linux/lib/stubs
 RUN ln -s /usr/lib/aarch64-linux-gnu/libcublas.so /usr/local/cuda/targets/aarch64-linux/lib/stubs/libcublas.so
 
+# Need the stub for libcuda.so in a place where host linker can find it to link the unit tests
+RUN ln -s /usr/local/cuda/targets/aarch64-linux/lib/stubs/libcuda.so /usr/lib/aarch64-linux-gnu/libcuda.so

Review comment:
       I'm referring to this part of the cmakelists:
   
   ```
     list(APPEND mxnet_LINKER_LIBS CUDA::cudart CUDA::cublas CUDA::cufft CUDA::cusolver CUDA::curand)
     if(ENABLE_CUDA_RTC)
       if(CUDA_nvrtc_LIBRARY)
         list(APPEND mxnet_LINKER_LIBS CUDA::nvrtc cuda)
         add_definitions(-DMXNET_ENABLE_CUDA_RTC=1)
       else()
         message(FATAL_ERROR "ENABLE_CUDA_RTC=ON, but failed to find NVRTC. CMake will exit." )
       endif()
     endif()
     list(APPEND SOURCE ${CUDA})
     add_definitions(-DMXNET_USE_CUDA=1)
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on a change in pull request #18622: Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r470413125



##########
File path: tests/python/unittest/test_sparse_operator.py
##########
@@ -1853,152 +1853,6 @@ def check_broadcast_div(mx_lhs, mx_rhs, np_lhs, np_rhs, dtype):
             check_broadcast_mul(mx_lhs, mx_rhs, np_lhs, np_rhs, np.float32)
             check_broadcast_div(mx_lhs, mx_rhs, np_lhs, np_rhs, np.float32)
 
-@with_seed()
-def test_scatter_ops():

Review comment:
       Those scatter ops were used long ago - introduced in #7903 to support sparse adagrad I think and then replaced in different implementation of adagrad in #9651. Still, the ops stayed, and since they were always in `_internal` space, I removed them instead of reworking them to RTC.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] leezu edited a comment on pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
leezu edited a comment on pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#issuecomment-654353049


   @ptrendx these are the files available in the S3 bucket. They are the files obtained from the SDK Manager. Is the file you are looking for included? If not, if you provide the file we can add it to the bucket.
   
   ```
   % aws s3 ls --recursive s3://mxnet-ci-prod-private-slave-data/nvidia                                                                                                                                   6s ~
   2020-04-11 02:46:49          0 nvidia/
   2020-04-11 02:47:05          0 nvidia/sdkm_downloads/
   2020-04-11 03:07:04  237414931 nvidia/sdkm_downloads/Jetson-210_Linux_R32.3.1_aarch64.tbz2
   2020-04-11 03:03:33  288481398 nvidia/sdkm_downloads/NVIDIA_Nsight_Graphics_L4T_2019.5.19322.deb
   2020-04-11 03:24:00    5350765 nvidia/sdkm_downloads/NVIDIA_VisionWorks_References.zip
   2020-04-11 03:17:26  113581742 nvidia/sdkm_downloads/NsightSystems-linux-public-2019.6.2.6-3ffb807.deb
   2020-04-11 03:24:08    1022926 nvidia/sdkm_downloads/OpenCV-4.1.1-2-gd5a58aa75-aarch64-dev.deb
   2020-04-11 03:23:59    9920774 nvidia/sdkm_downloads/OpenCV-4.1.1-2-gd5a58aa75-aarch64-libs.deb
   2020-04-11 03:24:13      14240 nvidia/sdkm_downloads/OpenCV-4.1.1-2-gd5a58aa75-aarch64-licenses.deb
   2020-04-11 03:24:07    2350538 nvidia/sdkm_downloads/OpenCV-4.1.1-2-gd5a58aa75-aarch64-python.deb
   2020-04-11 03:24:11     192038 nvidia/sdkm_downloads/OpenCV-4.1.1-2-gd5a58aa75-aarch64-samples.deb
   2020-04-11 03:24:09    1027754 nvidia/sdkm_downloads/OpenCV-4.1.1-2-gd5a58aa75-x86_64-dev.deb
   2020-04-11 03:21:58   45701978 nvidia/sdkm_downloads/OpenCV-4.1.1-2-gd5a58aa75-x86_64-libs.deb
   2020-04-11 03:24:12      18306 nvidia/sdkm_downloads/OpenCV-4.1.1-2-gd5a58aa75-x86_64-licenses.deb
   2020-04-11 03:24:03    2576742 nvidia/sdkm_downloads/OpenCV-4.1.1-2-gd5a58aa75-x86_64-python.deb
   2020-04-11 03:24:11     192030 nvidia/sdkm_downloads/OpenCV-4.1.1-2-gd5a58aa75-x86_64-samples.deb
   2020-04-11 03:24:11     143245 nvidia/sdkm_downloads/SDKM_logs_JetPack_4.3_Linux_for_Jetson_TX1_2020-04-10_17-43-23.zip
   2020-04-11 02:51:29 1263228889 nvidia/sdkm_downloads/Tegra_Linux_Sample-Root-Filesystem_R32.3.1_aarch64.tbz2
   2020-04-11 02:51:29  394475774 nvidia/sdkm_downloads/cuda-repo-cross-aarch64-10-0-local-10.0.326_1.0-1_all.deb
   2020-04-11 02:51:29 1000333292 nvidia/sdkm_downloads/cuda-repo-l4t-10-0-local-10.0.326_1.0-1_arm64.deb
   2020-04-11 02:51:29 1582667320 nvidia/sdkm_downloads/cuda-repo-ubuntu1804-10-0-local-10.0.326-410.108_1.0-1_amd64.deb
   2020-04-11 03:22:38   25538902 nvidia/sdkm_downloads/devtools_docs.zip
   2020-04-11 03:24:13      16108 nvidia/sdkm_downloads/graphsurgeon-tf_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 03:13:51  161324708 nvidia/sdkm_downloads/libcudnn7-dev_7.6.3.28-1+cuda10.0_arm64.deb
   2020-04-11 03:23:55    6627420 nvidia/sdkm_downloads/libcudnn7-doc_7.6.3.28-1+cuda10.0_arm64.deb
   2020-04-11 03:13:18  181721612 nvidia/sdkm_downloads/libcudnn7_7.6.3.28-1+cuda10.0_arm64.deb
   2020-04-11 03:24:13      12596 nvidia/sdkm_downloads/libnvidia-container-tools_0.9.0_beta.1_arm64.deb
   2020-04-11 03:24:12      42744 nvidia/sdkm_downloads/libnvidia-container0_0.9.0_beta.1_arm64.deb
   2020-04-11 03:24:12      69900 nvidia/sdkm_downloads/libnvinfer-bin_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 03:20:36   57300292 nvidia/sdkm_downloads/libnvinfer-dev_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 03:24:02    4460940 nvidia/sdkm_downloads/libnvinfer-doc_6.0.1-1+cuda10.0_all.deb
   2020-04-11 03:24:08    1546362 nvidia/sdkm_downloads/libnvinfer-plugin-dev_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 03:24:06    1489314 nvidia/sdkm_downloads/libnvinfer-plugin6_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 02:51:29  451737338 nvidia/sdkm_downloads/libnvinfer-samples_6.0.1-1+cuda10.0_all.deb
   2020-04-11 03:21:10   56443400 nvidia/sdkm_downloads/libnvinfer6_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 03:24:11     164522 nvidia/sdkm_downloads/libnvonnxparsers-dev_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 03:24:09     578042 nvidia/sdkm_downloads/libnvonnxparsers6_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 03:24:10     538398 nvidia/sdkm_downloads/libnvparsers-dev_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 03:24:08     707550 nvidia/sdkm_downloads/libnvparsers6_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 03:19:50   66561472 nvidia/sdkm_downloads/libvisionworks-repo_1.6.0.500n_amd64.deb
   2020-04-11 03:20:07   60780704 nvidia/sdkm_downloads/libvisionworks-repo_1.6.0.500n_arm64.deb
   2020-04-11 03:22:59   20597586 nvidia/sdkm_downloads/libvisionworks-sfm-repo_0.90.4_amd64.deb
   2020-04-11 03:23:08   20216850 nvidia/sdkm_downloads/libvisionworks-sfm-repo_0.90.4_arm64.deb
   2020-04-11 03:23:29   13113238 nvidia/sdkm_downloads/libvisionworks-tracking-repo_0.88.2_amd64.deb
   2020-04-11 03:23:56   13107966 nvidia/sdkm_downloads/libvisionworks-tracking-repo_0.88.2_arm64.deb
   2020-04-11 03:24:13      14842 nvidia/sdkm_downloads/nvidia-container-csv-cuda_10.0.326-1_arm64.deb
   2020-04-11 03:24:14       6176 nvidia/sdkm_downloads/nvidia-container-csv-cudnn_7.6.3.28-1+cuda10.0_arm64.deb
   2020-04-11 03:24:13      13686 nvidia/sdkm_downloads/nvidia-container-csv-tensorrt_6.0.1.10-1+cuda10.0_arm64.deb
   2020-04-11 03:24:12      29796 nvidia/sdkm_downloads/nvidia-container-csv-visionworks_1.6.0.500n_arm64.deb
   2020-04-11 03:24:09     534888 nvidia/sdkm_downloads/nvidia-container-runtime_3.1.0-1_arm64.deb
   2020-04-11 03:24:10     501768 nvidia/sdkm_downloads/nvidia-container-toolkit_1.0.1-1_arm64.deb
   2020-04-11 03:24:15       2940 nvidia/sdkm_downloads/nvidia-docker2_2.2.0-1_all.deb
   2020-04-11 03:18:20   70425180 nvidia/sdkm_downloads/nvidia-l4t-jetson-multimedia-api_32.3.1-20191209225816_arm64.deb
   2020-04-11 03:24:14       3632 nvidia/sdkm_downloads/python-libnvinfer-dev_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 03:24:10     363394 nvidia/sdkm_downloads/python-libnvinfer_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 03:24:14       3648 nvidia/sdkm_downloads/python3-libnvinfer-dev_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 03:24:10     360882 nvidia/sdkm_downloads/python3-libnvinfer_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 03:24:11     182539 nvidia/sdkm_downloads/sdkml3_jetpack_l4t_43_ga.json
   2020-04-11 03:24:14       3652 nvidia/sdkm_downloads/tensorrt_6.0.1.10-1+cuda10.0_arm64.deb
   2020-04-11 03:24:12      37802 nvidia/sdkm_downloads/uff-converter-tf_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 03:23:54    7959372 nvidia/sdkm_downloads/vpi-dev-0.1.0-r2-l4t-aarch64.deb
   2020-04-11 03:22:11   26794560 nvidia/sdkm_downloads/vpi-lib-0.1.0-r2-l4t-aarch64.deb
   2020-04-11 03:23:58    4491602 nvidia/sdkm_downloads/vpi-samples-0.1.0-r2-l4t-aarch64.deb
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] szha commented on a change in pull request #18622: Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
szha commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r470854357



##########
File path: docs/python_docs/python/tutorials/extend/index.rst
##########
@@ -47,6 +47,12 @@ The following tutorials will help you learn how to customize MXNet.
       How to create new MXNet operators in MXNet's backend using C++.
       An example custom quadratic function op.
 
+   .. card::
+      :title: Using runtime compilation (RTC) to write CUDA kernels in MXNet
+      :link: https://mxnet.apache.org/api/faq/using_rtc

Review comment:
       I'm currently fixing a number of issues in https://github.com/apache/incubator-mxnet/pull/18839. You may get conflict from this




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] szha commented on a change in pull request #18622: Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
szha commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r470299298



##########
File path: src/common/cuda/rtc/util-inl.h
##########
@@ -0,0 +1,380 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef MXNET_COMMON_CUDA_RTC_UTIL_INL_H_
+#define MXNET_COMMON_CUDA_RTC_UTIL_INL_H_
+
+#include <mxnet/base.h>
+
+#if MXNET_USE_CUDA
+
+namespace mxnet {
+namespace common {
+namespace cuda {
+namespace rtc {
+
+const char type_support_string[] = R"code(
+using float32 = float;
+using float64 = double;
+using float16 = half;
+using uint8 = unsigned char;
+using int8 = char;
+using int32 = int;
+using int64 = long long;

Review comment:
       will these ever be platform dependent?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ZiyueHuang commented on pull request #18622: Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ZiyueHuang commented on pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#issuecomment-678725081


   @ptrendx It works. Thanks for the fix.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] leezu commented on a change in pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
leezu commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r457573754



##########
File path: ci/docker/Dockerfile.build.jetson
##########
@@ -90,6 +90,9 @@ RUN wget https://repo.download.nvidia.com/jetson/x86_64/pool/r32.4/c/cuda/cuda-c
 # while previously it used to store it at /usr/local/cuda/targets/aarch64-linux/lib/stubs
 RUN ln -s /usr/lib/aarch64-linux-gnu/libcublas.so /usr/local/cuda/targets/aarch64-linux/lib/stubs/libcublas.so
 
+# Need the stub for libcuda.so in a place where host linker can find it to link the unit tests
+RUN ln -s /usr/local/cuda/targets/aarch64-linux/lib/stubs/libcuda.so /usr/lib/aarch64-linux-gnu/libcuda.so

Review comment:
       Do you know why `/usr/local/cuda/targets/aarch64-linux/lib/stubs/libcuda.so` is not detected by cmake? It shouldn't be necessary to create this symlink (it isn't necessary in the non-cross-compile setting). Have you reported a bug in the cmake repository?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] szha merged pull request #18622: Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
szha merged pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on a change in pull request #18622: Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r470738616



##########
File path: docs/python_docs/python/tutorials/extend/index.rst
##########
@@ -47,6 +47,12 @@ The following tutorials will help you learn how to customize MXNet.
       How to create new MXNet operators in MXNet's backend using C++.
       An example custom quadratic function op.
 
+   .. card::
+      :title: Using runtime compilation (RTC) to write CUDA kernels in MXNet
+      :link: https://mxnet.apache.org/api/faq/using_rtc

Review comment:
       Ok - I was just copy-pasting from the other sections there (like add_op_in_backend). Will update those as well.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on a change in pull request #18622: Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r470852890



##########
File path: docs/python_docs/python/tutorials/extend/index.rst
##########
@@ -47,6 +47,12 @@ The following tutorials will help you learn how to customize MXNet.
       How to create new MXNet operators in MXNet's backend using C++.
       An example custom quadratic function op.
 
+   .. card::
+      :title: Using runtime compilation (RTC) to write CUDA kernels in MXNet
+      :link: https://mxnet.apache.org/api/faq/using_rtc

Review comment:
       Yeah, I tried putting those relative links in the toctree as well and building of Python docs complains with
   ```
   /work/mxnet/docs/python_docs/python/build/tutorials/extend/index.rst:57: WARNING: toctree contains reference to nonexisting document 'api/faq/new_op'                                                              
   /work/mxnet/docs/python_docs/python/build/tutorials/extend/index.rst:57: WARNING: toctree contains reference to nonexisting document 'api/faq/add_op_in_backend'                           
   /work/mxnet/docs/python_docs/python/build/tutorials/extend/index.rst:57: WARNING: toctree contains reference to nonexisting document 'api/faq/using_rtc'
   ```
   and those entries are not shown in the final website.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#issuecomment-652530754


   Jenkins CI successfully triggered : [unix-gpu, website, miscellaneous, windows-gpu, clang, sanity, centos-gpu]


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on a change in pull request #18622: Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r470704297



##########
File path: src/common/cuda/rtc/util-inl.h
##########
@@ -0,0 +1,380 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef MXNET_COMMON_CUDA_RTC_UTIL_INL_H_
+#define MXNET_COMMON_CUDA_RTC_UTIL_INL_H_
+
+#include <mxnet/base.h>
+
+#if MXNET_USE_CUDA
+
+namespace mxnet {
+namespace common {
+namespace cuda {
+namespace rtc {
+
+const char type_support_string[] = R"code(
+using float32 = float;
+using float64 = double;
+using float16 = half;
+using uint8 = unsigned char;
+using int8 = char;
+using int32 = int;
+using int64 = long long;

Review comment:
       They come from the standard builtin types on a given platform. That said, I see your point - I will add some static asserts to ensure that the size is what we expect.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#issuecomment-662091126


   @eric-haibin-lin Yes. A lot of the code (compilation related as well as the function definitions) was moved around to be able to be reused. Support for NumPy-style mixed types were also added.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on pull request #18622: Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#issuecomment-678653890


   @ZiyueHuang Please try with PR #18984.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] szha commented on a change in pull request #18622: Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
szha commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r470301994



##########
File path: tests/python/unittest/test_operator.py
##########
@@ -9337,4 +9337,82 @@ def test_elemwise_sum_for_gradient_accumulation():
         assert stored_grad['write'] == stored_grad['add']
         assert stored_grad['write'] == 2 * nrepeat
 
+@with_seed()
+def test_elementwise_ops_on_misaligned_input():

Review comment:
       it would be great to have the numpy equivalent of them too, in tests/python/unittest/test_numpy_op.py




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] leezu commented on a change in pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
leezu commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r457769003



##########
File path: src/common/cuda/rtc.cc
##########
@@ -0,0 +1,246 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "mxnet/base.h"
+
+#if MXNET_USE_CUDA
+
+#include <nvrtc.h>
+
+#include <mutex>
+#include <string>
+#include <fstream>
+#include <unordered_map>
+#include <vector>
+
+#include "rtc.h"
+#include "rtc/half-inl.h"
+#include "rtc/util-inl.h"
+#include "rtc/forward_functions-inl.h"
+#include "rtc/backward_functions-inl.h"
+#include "rtc/vectorization-inl.h"
+#include "rtc/special_functions-inl.h"
+#include "rtc/reducer-inl.h"
+#include "utils.h"
+
+
+namespace mxnet {
+namespace common {
+namespace cuda {
+namespace rtc {
+
+std::mutex lock;
+
+namespace util {
+
+std::string to_string(OpReqType req) {
+  switch (req) {
+    case kNullOp:
+      return "OpReqType::kNullOp";
+    case kWriteTo:
+    case kWriteInplace:
+      return "OpReqType::kWriteTo";
+    case kAddTo:
+      return "OpReqType::kAddTo";
+  }
+  LOG(FATAL) << "Unrecognized req.";
+  return "";
+}
+
+}  // namespace util
+
+namespace {
+
+// Obtain compilation log from the program.
+std::string GetCompileLog(nvrtcProgram program) {
+  size_t log_size_including_null;
+  NVRTC_CALL(nvrtcGetProgramLogSize(program, &log_size_including_null));
+  // For most std::string implementations, this is probably 1 char bigger than needed.  OK though.

Review comment:
       Thank you for clarifying @DickJC123.
   
   > I think most implementations of std::string will add 1 to the size you give at string construction time, because they want an efficient implementation of string::c_str(). So it would probably work, but why risk it?
   
   As of C++11, the standard guarantees that "a pointer to s[0] can be passed to functions that expect a pointer to the first element of a null-terminated CharT[] array" according to https://en.cppreference.com/w/cpp/string/basic_string. Ie the pointer returned by `s.c_str()` must be the same as as the pointer to `s[0]`. So there would be no risk in allocating the string of true size and avoid the extra resize.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on a change in pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r458221543



##########
File path: src/common/cuda/rtc.cc
##########
@@ -0,0 +1,246 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "mxnet/base.h"
+
+#if MXNET_USE_CUDA
+
+#include <nvrtc.h>
+
+#include <mutex>
+#include <string>
+#include <fstream>
+#include <unordered_map>
+#include <vector>
+
+#include "rtc.h"
+#include "rtc/half-inl.h"
+#include "rtc/util-inl.h"
+#include "rtc/forward_functions-inl.h"
+#include "rtc/backward_functions-inl.h"
+#include "rtc/vectorization-inl.h"
+#include "rtc/special_functions-inl.h"
+#include "rtc/reducer-inl.h"
+#include "utils.h"
+
+
+namespace mxnet {
+namespace common {
+namespace cuda {
+namespace rtc {
+
+std::mutex lock;
+
+namespace util {
+
+std::string to_string(OpReqType req) {
+  switch (req) {
+    case kNullOp:
+      return "OpReqType::kNullOp";
+    case kWriteTo:
+    case kWriteInplace:
+      return "OpReqType::kWriteTo";
+    case kAddTo:
+      return "OpReqType::kAddTo";
+  }
+  LOG(FATAL) << "Unrecognized req.";
+  return "";
+}
+
+}  // namespace util
+
+namespace {
+
+// Obtain compilation log from the program.
+std::string GetCompileLog(nvrtcProgram program) {
+  size_t log_size_including_null;
+  NVRTC_CALL(nvrtcGetProgramLogSize(program, &log_size_including_null));
+  // For most std::string implementations, this is probably 1 char bigger than needed.  OK though.

Review comment:
       @DickJC123 If you read the `data` and `operator[]` paragraphs from the Microsoft documentation that you linked, you will see that they do actually say the same thing (just in a more convoluted way):
    - from `data`: `Prior to C++11, data didn't guarantee the returned string was null-terminated. Since C++11, data and c_str both return a null-terminated string, and are effectively the same.`
    - from `operator[]`: ` An invalid index passed to operator[] results in undefined behavior, but the index equal to the length of the string is a valid index for const strings and the operator returns the null character when passed this index.`




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on pull request #18622: Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#issuecomment-670771199


   @eric-haibin-lin Yes. The overhead comes from preparing a string with kernel options (like the datatypes) and searching for the kernel function in cache. CUDA graph caches the resulting function so the lookup does not occur anymore.
   
   That said, this overhead is lower than the overhead of `cudaLaunchKernel` itself and is barely noticeable - I tried it with a worst case scenario of fully hybridized model that was adding tensors with single element (to be 100% CPU limited) and got ~10% slowdown. More realistic workload with kernels taking longer than a few us would not show any difference. The same CPU limited test with non-hybridized model did not show noticeable slowdown (overheads of imperative mode are way higher than this).


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] szha commented on a change in pull request #18622: Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
szha commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r470293845



##########
File path: docs/python_docs/python/tutorials/extend/index.rst
##########
@@ -47,6 +47,12 @@ The following tutorials will help you learn how to customize MXNet.
       How to create new MXNet operators in MXNet's backend using C++.
       An example custom quadratic function op.
 
+   .. card::
+      :title: Using runtime compilation (RTC) to write CUDA kernels in MXNet
+      :link: https://mxnet.apache.org/api/faq/using_rtc

Review comment:
       use `:link: /api/faq/using_rtc` instead as the documentation is versioned.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] leezu edited a comment on pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
leezu edited a comment on pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#issuecomment-650325459


   > Also, I thought that you made the compilation use C++17 (so I use `if constexpr`), but now I see that the CUDA part is compiled with C++14 (and fails). What is the reason of that?
   
   The reason is that CUDA does not support C++17 prior to CUDA11. Thus cuda files are compiled with C++14. We can consider requiring CUDA11 for MXNet 2


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] szha commented on a change in pull request #18622: Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
szha commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r470301774



##########
File path: tests/python/unittest/test_sparse_operator.py
##########
@@ -1853,152 +1853,6 @@ def check_broadcast_div(mx_lhs, mx_rhs, np_lhs, np_rhs, dtype):
             check_broadcast_mul(mx_lhs, mx_rhs, np_lhs, np_rhs, np.float32)
             check_broadcast_div(mx_lhs, mx_rhs, np_lhs, np_rhs, np.float32)
 
-@with_seed()
-def test_scatter_ops():

Review comment:
       cc @eric-haibin-lin to confirm




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on a change in pull request #18622: Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r471598945



##########
File path: docs/python_docs/python/tutorials/extend/index.rst
##########
@@ -47,6 +47,12 @@ The following tutorials will help you learn how to customize MXNet.
       How to create new MXNet operators in MXNet's backend using C++.
       An example custom quadratic function op.
 
+   .. card::
+      :title: Using runtime compilation (RTC) to write CUDA kernels in MXNet
+      :link: https://mxnet.apache.org/api/faq/using_rtc

Review comment:
       #18839 is merged, but it did not tackle the issue of toctree - should I leave the links as they are right now @szha?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] DickJC123 commented on a change in pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
DickJC123 commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r457779449



##########
File path: src/common/cuda/rtc.cc
##########
@@ -0,0 +1,246 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "mxnet/base.h"
+
+#if MXNET_USE_CUDA
+
+#include <nvrtc.h>
+
+#include <mutex>
+#include <string>
+#include <fstream>
+#include <unordered_map>
+#include <vector>
+
+#include "rtc.h"
+#include "rtc/half-inl.h"
+#include "rtc/util-inl.h"
+#include "rtc/forward_functions-inl.h"
+#include "rtc/backward_functions-inl.h"
+#include "rtc/vectorization-inl.h"
+#include "rtc/special_functions-inl.h"
+#include "rtc/reducer-inl.h"
+#include "utils.h"
+
+
+namespace mxnet {
+namespace common {
+namespace cuda {
+namespace rtc {
+
+std::mutex lock;
+
+namespace util {
+
+std::string to_string(OpReqType req) {
+  switch (req) {
+    case kNullOp:
+      return "OpReqType::kNullOp";
+    case kWriteTo:
+    case kWriteInplace:
+      return "OpReqType::kWriteTo";
+    case kAddTo:
+      return "OpReqType::kAddTo";
+  }
+  LOG(FATAL) << "Unrecognized req.";
+  return "";
+}
+
+}  // namespace util
+
+namespace {
+
+// Obtain compilation log from the program.
+std::string GetCompileLog(nvrtcProgram program) {
+  size_t log_size_including_null;
+  NVRTC_CALL(nvrtcGetProgramLogSize(program, &log_size_including_null));
+  // For most std::string implementations, this is probably 1 char bigger than needed.  OK though.

Review comment:
       I studied your link more carefully and think my post above missed your point.  Studying it further, I agree now that the following would work under C++11:
   ```
   std::string GetCompileLog(nvrtcProgram program) {
     size_t log_size_including_null;
     NVRTC_CALL(nvrtcGetProgramLogSize(program, &log_size_including_null));
     std::string log(log_size_including_null-1, '\0');
     // Room for terminating null character ensured since C++11
     NVRTC_CALL(nvrtcGetProgramLog(program, &log[0]));
     return log;
   }
   ```
   I guess with the version currently in the PR, I was being conservative, not wanting to research the level of C++11 support in all the compilers MXNet was going to see.  Do you see any difference between &log[0] and log.data() in terms of ensuring the compiler adheres to its contract of providing size()+1 bytes of contiguous storage?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on a change in pull request #18622: Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r470413705



##########
File path: src/common/cuda/rtc/util-inl.h
##########
@@ -0,0 +1,380 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef MXNET_COMMON_CUDA_RTC_UTIL_INL_H_
+#define MXNET_COMMON_CUDA_RTC_UTIL_INL_H_
+
+#include <mxnet/base.h>
+
+#if MXNET_USE_CUDA
+
+namespace mxnet {
+namespace common {
+namespace cuda {
+namespace rtc {
+
+const char type_support_string[] = R"code(
+using float32 = float;
+using float64 = double;
+using float16 = half;
+using uint8 = unsigned char;
+using int8 = char;
+using int32 = int;
+using int64 = long long;

Review comment:
       Not sure what you mean by that - are you asking about `long long` in particular or all of those? The problem with RTC is that it is not really easy to include anything external, especially system headers, so I need to use built-in types - otherwise I would use stuff like `int64_t` here.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] leezu commented on pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
leezu commented on pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#issuecomment-654353049


   @ptrendx these are the files available in the S3 bucket. You may need to edit the Dockerfile to install one of the debs:
   
   ```
   % aws s3 ls --recursive s3://mxnet-ci-prod-private-slave-data/nvidia                                                                                                                                   6s ~
   2020-04-11 02:46:49          0 nvidia/
   2020-04-11 02:47:05          0 nvidia/sdkm_downloads/
   2020-04-11 03:07:04  237414931 nvidia/sdkm_downloads/Jetson-210_Linux_R32.3.1_aarch64.tbz2
   2020-04-11 03:03:33  288481398 nvidia/sdkm_downloads/NVIDIA_Nsight_Graphics_L4T_2019.5.19322.deb
   2020-04-11 03:24:00    5350765 nvidia/sdkm_downloads/NVIDIA_VisionWorks_References.zip
   2020-04-11 03:17:26  113581742 nvidia/sdkm_downloads/NsightSystems-linux-public-2019.6.2.6-3ffb807.deb
   2020-04-11 03:24:08    1022926 nvidia/sdkm_downloads/OpenCV-4.1.1-2-gd5a58aa75-aarch64-dev.deb
   2020-04-11 03:23:59    9920774 nvidia/sdkm_downloads/OpenCV-4.1.1-2-gd5a58aa75-aarch64-libs.deb
   2020-04-11 03:24:13      14240 nvidia/sdkm_downloads/OpenCV-4.1.1-2-gd5a58aa75-aarch64-licenses.deb
   2020-04-11 03:24:07    2350538 nvidia/sdkm_downloads/OpenCV-4.1.1-2-gd5a58aa75-aarch64-python.deb
   2020-04-11 03:24:11     192038 nvidia/sdkm_downloads/OpenCV-4.1.1-2-gd5a58aa75-aarch64-samples.deb
   2020-04-11 03:24:09    1027754 nvidia/sdkm_downloads/OpenCV-4.1.1-2-gd5a58aa75-x86_64-dev.deb
   2020-04-11 03:21:58   45701978 nvidia/sdkm_downloads/OpenCV-4.1.1-2-gd5a58aa75-x86_64-libs.deb
   2020-04-11 03:24:12      18306 nvidia/sdkm_downloads/OpenCV-4.1.1-2-gd5a58aa75-x86_64-licenses.deb
   2020-04-11 03:24:03    2576742 nvidia/sdkm_downloads/OpenCV-4.1.1-2-gd5a58aa75-x86_64-python.deb
   2020-04-11 03:24:11     192030 nvidia/sdkm_downloads/OpenCV-4.1.1-2-gd5a58aa75-x86_64-samples.deb
   2020-04-11 03:24:11     143245 nvidia/sdkm_downloads/SDKM_logs_JetPack_4.3_Linux_for_Jetson_TX1_2020-04-10_17-43-23.zip
   2020-04-11 02:51:29 1263228889 nvidia/sdkm_downloads/Tegra_Linux_Sample-Root-Filesystem_R32.3.1_aarch64.tbz2
   2020-04-11 02:51:29  394475774 nvidia/sdkm_downloads/cuda-repo-cross-aarch64-10-0-local-10.0.326_1.0-1_all.deb
   2020-04-11 02:51:29 1000333292 nvidia/sdkm_downloads/cuda-repo-l4t-10-0-local-10.0.326_1.0-1_arm64.deb
   2020-04-11 02:51:29 1582667320 nvidia/sdkm_downloads/cuda-repo-ubuntu1804-10-0-local-10.0.326-410.108_1.0-1_amd64.deb
   2020-04-11 03:22:38   25538902 nvidia/sdkm_downloads/devtools_docs.zip
   2020-04-11 03:24:13      16108 nvidia/sdkm_downloads/graphsurgeon-tf_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 03:13:51  161324708 nvidia/sdkm_downloads/libcudnn7-dev_7.6.3.28-1+cuda10.0_arm64.deb
   2020-04-11 03:23:55    6627420 nvidia/sdkm_downloads/libcudnn7-doc_7.6.3.28-1+cuda10.0_arm64.deb
   2020-04-11 03:13:18  181721612 nvidia/sdkm_downloads/libcudnn7_7.6.3.28-1+cuda10.0_arm64.deb
   2020-04-11 03:24:13      12596 nvidia/sdkm_downloads/libnvidia-container-tools_0.9.0_beta.1_arm64.deb
   2020-04-11 03:24:12      42744 nvidia/sdkm_downloads/libnvidia-container0_0.9.0_beta.1_arm64.deb
   2020-04-11 03:24:12      69900 nvidia/sdkm_downloads/libnvinfer-bin_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 03:20:36   57300292 nvidia/sdkm_downloads/libnvinfer-dev_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 03:24:02    4460940 nvidia/sdkm_downloads/libnvinfer-doc_6.0.1-1+cuda10.0_all.deb
   2020-04-11 03:24:08    1546362 nvidia/sdkm_downloads/libnvinfer-plugin-dev_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 03:24:06    1489314 nvidia/sdkm_downloads/libnvinfer-plugin6_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 02:51:29  451737338 nvidia/sdkm_downloads/libnvinfer-samples_6.0.1-1+cuda10.0_all.deb
   2020-04-11 03:21:10   56443400 nvidia/sdkm_downloads/libnvinfer6_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 03:24:11     164522 nvidia/sdkm_downloads/libnvonnxparsers-dev_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 03:24:09     578042 nvidia/sdkm_downloads/libnvonnxparsers6_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 03:24:10     538398 nvidia/sdkm_downloads/libnvparsers-dev_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 03:24:08     707550 nvidia/sdkm_downloads/libnvparsers6_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 03:19:50   66561472 nvidia/sdkm_downloads/libvisionworks-repo_1.6.0.500n_amd64.deb
   2020-04-11 03:20:07   60780704 nvidia/sdkm_downloads/libvisionworks-repo_1.6.0.500n_arm64.deb
   2020-04-11 03:22:59   20597586 nvidia/sdkm_downloads/libvisionworks-sfm-repo_0.90.4_amd64.deb
   2020-04-11 03:23:08   20216850 nvidia/sdkm_downloads/libvisionworks-sfm-repo_0.90.4_arm64.deb
   2020-04-11 03:23:29   13113238 nvidia/sdkm_downloads/libvisionworks-tracking-repo_0.88.2_amd64.deb
   2020-04-11 03:23:56   13107966 nvidia/sdkm_downloads/libvisionworks-tracking-repo_0.88.2_arm64.deb
   2020-04-11 03:24:13      14842 nvidia/sdkm_downloads/nvidia-container-csv-cuda_10.0.326-1_arm64.deb
   2020-04-11 03:24:14       6176 nvidia/sdkm_downloads/nvidia-container-csv-cudnn_7.6.3.28-1+cuda10.0_arm64.deb
   2020-04-11 03:24:13      13686 nvidia/sdkm_downloads/nvidia-container-csv-tensorrt_6.0.1.10-1+cuda10.0_arm64.deb
   2020-04-11 03:24:12      29796 nvidia/sdkm_downloads/nvidia-container-csv-visionworks_1.6.0.500n_arm64.deb
   2020-04-11 03:24:09     534888 nvidia/sdkm_downloads/nvidia-container-runtime_3.1.0-1_arm64.deb
   2020-04-11 03:24:10     501768 nvidia/sdkm_downloads/nvidia-container-toolkit_1.0.1-1_arm64.deb
   2020-04-11 03:24:15       2940 nvidia/sdkm_downloads/nvidia-docker2_2.2.0-1_all.deb
   2020-04-11 03:18:20   70425180 nvidia/sdkm_downloads/nvidia-l4t-jetson-multimedia-api_32.3.1-20191209225816_arm64.deb
   2020-04-11 03:24:14       3632 nvidia/sdkm_downloads/python-libnvinfer-dev_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 03:24:10     363394 nvidia/sdkm_downloads/python-libnvinfer_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 03:24:14       3648 nvidia/sdkm_downloads/python3-libnvinfer-dev_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 03:24:10     360882 nvidia/sdkm_downloads/python3-libnvinfer_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 03:24:11     182539 nvidia/sdkm_downloads/sdkml3_jetpack_l4t_43_ga.json
   2020-04-11 03:24:14       3652 nvidia/sdkm_downloads/tensorrt_6.0.1.10-1+cuda10.0_arm64.deb
   2020-04-11 03:24:12      37802 nvidia/sdkm_downloads/uff-converter-tf_6.0.1-1+cuda10.0_arm64.deb
   2020-04-11 03:23:54    7959372 nvidia/sdkm_downloads/vpi-dev-0.1.0-r2-l4t-aarch64.deb
   2020-04-11 03:22:11   26794560 nvidia/sdkm_downloads/vpi-lib-0.1.0-r2-l4t-aarch64.deb
   2020-04-11 03:23:58    4491602 nvidia/sdkm_downloads/vpi-samples-0.1.0-r2-l4t-aarch64.deb
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on a change in pull request #18622: Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r470774692



##########
File path: tests/python/unittest/test_operator.py
##########
@@ -9337,4 +9337,82 @@ def test_elemwise_sum_for_gradient_accumulation():
         assert stored_grad['write'] == stored_grad['add']
         assert stored_grad['write'] == 2 * nrepeat
 
+@with_seed()
+def test_elementwise_ops_on_misaligned_input():

Review comment:
       :+1:




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on a change in pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r457584073



##########
File path: ci/docker/Dockerfile.build.jetson
##########
@@ -90,6 +90,9 @@ RUN wget https://repo.download.nvidia.com/jetson/x86_64/pool/r32.4/c/cuda/cuda-c
 # while previously it used to store it at /usr/local/cuda/targets/aarch64-linux/lib/stubs
 RUN ln -s /usr/lib/aarch64-linux-gnu/libcublas.so /usr/local/cuda/targets/aarch64-linux/lib/stubs/libcublas.so
 
+# Need the stub for libcuda.so in a place where host linker can find it to link the unit tests
+RUN ln -s /usr/local/cuda/targets/aarch64-linux/lib/stubs/libcuda.so /usr/lib/aarch64-linux-gnu/libcuda.so

Review comment:
       It is detected by cmake, but only for CUDA compilation - the problem happens during the compilation of mxnet_unit_tests, which is not CUDA-aware I believe.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] ptrendx commented on a change in pull request #18622: [WIP] Use RTC for elementwise and broadcast ops

Posted by GitBox <gi...@apache.org>.
ptrendx commented on a change in pull request #18622:
URL: https://github.com/apache/incubator-mxnet/pull/18622#discussion_r457642828



##########
File path: ci/docker/Dockerfile.build.jetson
##########
@@ -90,6 +90,9 @@ RUN wget https://repo.download.nvidia.com/jetson/x86_64/pool/r32.4/c/cuda/cuda-c
 # while previously it used to store it at /usr/local/cuda/targets/aarch64-linux/lib/stubs
 RUN ln -s /usr/lib/aarch64-linux-gnu/libcublas.so /usr/local/cuda/targets/aarch64-linux/lib/stubs/libcublas.so
 
+# Need the stub for libcuda.so in a place where host linker can find it to link the unit tests
+RUN ln -s /usr/local/cuda/targets/aarch64-linux/lib/stubs/libcuda.so /usr/lib/aarch64-linux-gnu/libcuda.so

Review comment:
       Seems to be working :-). Thanks for the suggestion!




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org