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/10/16 22:41:18 UTC
[GitHub] [incubator-mxnet] ptrendx opened a new pull request #19364: Make RTC compatible with CUDA enhanced compatibility
ptrendx opened a new pull request #19364:
URL: https://github.com/apache/incubator-mxnet/pull/19364
## Description ##
Starting with CUDA 11.1 it is possible to run programs compiled with newer CUDA toolkit with older driver (as long as the major version is the same, e.g. CUDA 11.1 works with CUDA 11.0 driver) without the compat library. This requires a few changes to API used by nvRTC however, which are addressed by this PR.
## Checklist ##
### Essentials ###
- [x] Changes are complete (i.e. I finished coding on this PR)
- [x] Code is well-documented
## Comments ##
- Change was tested in internal CI using CUDA 11.1 toolkit and Titan RTX with 450.80.02 driver.
----------------------------------------------------------------
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 #19364: Make RTC compatible with CUDA enhanced compatibility
Posted by GitBox <gi...@apache.org>.
ptrendx commented on pull request #19364:
URL: https://github.com/apache/incubator-mxnet/pull/19364#issuecomment-721282207
@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] ptrendx commented on pull request #19364: Make RTC compatible with CUDA enhanced compatibility
Posted by GitBox <gi...@apache.org>.
ptrendx commented on pull request #19364:
URL: https://github.com/apache/incubator-mxnet/pull/19364#issuecomment-711122471
Are there any people using it? The interface is not great, since the CudaModule from there is not even an operator so can't be used in a model. We could reuse the recent RTC stuff to make it much better experience (and actually potentially pretty useful).
That said, this PR does not touch that functionality (because the compilation options there are set by the user). I could make it so if you specify the proper option (`--gpu-architecture=sm_XX` insteaf of `compute_XX` yourself) it gets the cubin instead of ptx so it works with enhanced compatibility.
----------------------------------------------------------------
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 #19364: Make RTC compatible with CUDA enhanced compatibility
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #19364:
URL: https://github.com/apache/incubator-mxnet/pull/19364#issuecomment-721282259
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 a change in pull request #19364: Make RTC compatible with CUDA enhanced compatibility
Posted by GitBox <gi...@apache.org>.
ptrendx commented on a change in pull request #19364:
URL: https://github.com/apache/incubator-mxnet/pull/19364#discussion_r516236025
##########
File path: src/common/cuda/rtc.cc
##########
@@ -78,15 +80,47 @@ std::string GetCompileLog(nvrtcProgram program) {
}
// Obtain compilation result (ptx assembly) from the program.
-std::string GetPtx(nvrtcProgram program) {
+std::string GetCompiledCode(nvrtcProgram program, bool use_cubin) {
+#if CUDA_VERSION >= 11010
+ const auto getSize = use_cubin ? nvrtcGetCUBINSize : nvrtcGetPTXSize;
+ const auto getFunc = use_cubin ? nvrtcGetCUBIN : nvrtcGetPTX;
+#else
+ const auto getSize = nvrtcGetPTXSize;
+ const auto getFunc = nvrtcGetPTX;
+#endif
size_t ptx_size_including_null;
- NVRTC_CALL(nvrtcGetPTXSize(program, &ptx_size_including_null));
+ NVRTC_CALL(getSize(program, &ptx_size_including_null));
std::string ptx(ptx_size_including_null - 1, '\0');
// Room for terminating null character ensured since C++11
- NVRTC_CALL(nvrtcGetPTX(program, &ptx[0]));
+ NVRTC_CALL(getFunc(program, &ptx[0]));
return ptx;
}
+std::tuple<bool, std::string> GetArchString(const int sm_arch) {
+#if CUDA_VERSION < 10000
+ constexpr int max_supported_sm_arch = 70;
Review comment:
:+1:
##########
File path: src/common/rtc.cc
##########
@@ -55,10 +55,30 @@ CudaModule::Chunk::Chunk(
LOG(FATAL) << err.data();
}
- size_t ptx_size;
- NVRTC_CALL(nvrtcGetPTXSize(prog_, &ptx_size));
- ptx_ = new char[ptx_size];
- NVRTC_CALL(nvrtcGetPTX(prog_, ptx_));
+ bool use_ptx = true;
+ for (const auto& opt : options) {
+ if (opt.find("sm_") != std::string::npos) {
+ use_ptx = false;
+ break;
+ }
+ }
+
+ if (use_ptx) {
+ size_t ptx_size;
+ NVRTC_CALL(nvrtcGetPTXSize(prog_, &ptx_size));
+ ptx_.resize(ptx_size);
+ NVRTC_CALL(nvrtcGetPTX(prog_, ptx_.data()));
+ } else {
+#if CUDA_VERSION >= 11010
+ size_t cubin_size;
+ NVRTC_CALL(nvrtcGetCUBINSize(prog_, &cubin_size));
+ ptx_.resize(ptx_size);
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 #19364: Make RTC compatible with CUDA enhanced compatibility
Posted by GitBox <gi...@apache.org>.
ptrendx commented on pull request #19364:
URL: https://github.com/apache/incubator-mxnet/pull/19364#issuecomment-713023891
@mxnet-bot run ci [centos-cpu, centos-gpu, edge, miscellaneous]
----------------------------------------------------------------
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 pull request #19364: Make RTC compatible with CUDA enhanced compatibility
Posted by GitBox <gi...@apache.org>.
szha commented on pull request #19364:
URL: https://github.com/apache/incubator-mxnet/pull/19364#issuecomment-711078144
I think we need to continue to support mx.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] mxnet-bot commented on pull request #19364: Make RTC compatible with CUDA enhanced compatibility
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #19364:
URL: https://github.com/apache/incubator-mxnet/pull/19364#issuecomment-713023958
Jenkins CI successfully triggered : [edge, centos-cpu, miscellaneous, 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] mxnet-bot commented on pull request #19364: Make RTC compatible with CUDA enhanced compatibility
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #19364:
URL: https://github.com/apache/incubator-mxnet/pull/19364#issuecomment-715512074
Jenkins CI successfully triggered : [edge, website, unix-gpu, centos-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] szha commented on pull request #19364: Make RTC compatible with CUDA enhanced compatibility
Posted by GitBox <gi...@apache.org>.
szha commented on pull request #19364:
URL: https://github.com/apache/incubator-mxnet/pull/19364#issuecomment-711169788
Agreed. In 2.0 we can change the interface.
----------------------------------------------------------------
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 merged pull request #19364: Make RTC compatible with CUDA enhanced compatibility
Posted by GitBox <gi...@apache.org>.
DickJC123 merged pull request #19364:
URL: https://github.com/apache/incubator-mxnet/pull/19364
----------------------------------------------------------------
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 #19364: Make RTC compatible with CUDA enhanced compatibility
Posted by GitBox <gi...@apache.org>.
ptrendx commented on pull request #19364:
URL: https://github.com/apache/incubator-mxnet/pull/19364#issuecomment-715512015
@mxnet-bot run ci [centos-cpu, unix-gpu, edge, 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] DickJC123 commented on a change in pull request #19364: Make RTC compatible with CUDA enhanced compatibility
Posted by GitBox <gi...@apache.org>.
DickJC123 commented on a change in pull request #19364:
URL: https://github.com/apache/incubator-mxnet/pull/19364#discussion_r514640981
##########
File path: src/common/cuda/rtc.cc
##########
@@ -78,15 +80,47 @@ std::string GetCompileLog(nvrtcProgram program) {
}
// Obtain compilation result (ptx assembly) from the program.
-std::string GetPtx(nvrtcProgram program) {
+std::string GetCompiledCode(nvrtcProgram program, bool use_cubin) {
+#if CUDA_VERSION >= 11010
+ const auto getSize = use_cubin ? nvrtcGetCUBINSize : nvrtcGetPTXSize;
+ const auto getFunc = use_cubin ? nvrtcGetCUBIN : nvrtcGetPTX;
+#else
+ const auto getSize = nvrtcGetPTXSize;
+ const auto getFunc = nvrtcGetPTX;
+#endif
size_t ptx_size_including_null;
- NVRTC_CALL(nvrtcGetPTXSize(program, &ptx_size_including_null));
+ NVRTC_CALL(getSize(program, &ptx_size_including_null));
std::string ptx(ptx_size_including_null - 1, '\0');
// Room for terminating null character ensured since C++11
- NVRTC_CALL(nvrtcGetPTX(program, &ptx[0]));
+ NVRTC_CALL(getFunc(program, &ptx[0]));
return ptx;
}
+std::tuple<bool, std::string> GetArchString(const int sm_arch) {
+#if CUDA_VERSION < 10000
+ constexpr int max_supported_sm_arch = 70;
Review comment:
Jetson TX2, sm arch 72, was supported under cuda 9.0. Any value in changing 70 -> 72?
##########
File path: src/common/rtc.cc
##########
@@ -55,10 +55,30 @@ CudaModule::Chunk::Chunk(
LOG(FATAL) << err.data();
}
- size_t ptx_size;
- NVRTC_CALL(nvrtcGetPTXSize(prog_, &ptx_size));
- ptx_ = new char[ptx_size];
- NVRTC_CALL(nvrtcGetPTX(prog_, ptx_));
+ bool use_ptx = true;
+ for (const auto& opt : options) {
+ if (opt.find("sm_") != std::string::npos) {
+ use_ptx = false;
+ break;
+ }
+ }
+
+ if (use_ptx) {
+ size_t ptx_size;
+ NVRTC_CALL(nvrtcGetPTXSize(prog_, &ptx_size));
+ ptx_.resize(ptx_size);
+ NVRTC_CALL(nvrtcGetPTX(prog_, ptx_.data()));
+ } else {
+#if CUDA_VERSION >= 11010
+ size_t cubin_size;
+ NVRTC_CALL(nvrtcGetCUBINSize(prog_, &cubin_size));
+ ptx_.resize(ptx_size);
Review comment:
```suggestion
ptx_.resize(cubin_size);
```
##########
File path: src/common/cuda/rtc.cc
##########
@@ -78,15 +80,47 @@ std::string GetCompileLog(nvrtcProgram program) {
}
// Obtain compilation result (ptx assembly) from the program.
-std::string GetPtx(nvrtcProgram program) {
+std::string GetCompiledCode(nvrtcProgram program, bool use_cubin) {
+#if CUDA_VERSION >= 11010
+ const auto getSize = use_cubin ? nvrtcGetCUBINSize : nvrtcGetPTXSize;
+ const auto getFunc = use_cubin ? nvrtcGetCUBIN : nvrtcGetPTX;
Review comment:
FWIW, while nvrtcGetCUBINSize() and nvrtcGetCUBIN() are not yet in the nvrtc docs, their use is described in https://docs.nvidia.com/deploy/cuda-compatibility/
----------------------------------------------------------------
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 #19364: Make RTC compatible with CUDA enhanced compatibility
Posted by GitBox <gi...@apache.org>.
ptrendx commented on pull request #19364:
URL: https://github.com/apache/incubator-mxnet/pull/19364#issuecomment-710684314
Note: this does not touch the legacy RTC part (https://mxnet.apache.org/versions/1.6/api/python/docs/api/mxnet/rtc/index.html) - what is the plan for it @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