Commit 20ddd2b5 by ghostplant Committed by Tianqi Chen

Avoid using heavy API to query single attribution (#3179)

parent 605b5e60
......@@ -84,12 +84,13 @@ std::string NVRTCCompile(const std::string& code, bool include_path = false) {
std::vector<std::string> compile_params;
std::vector<const char*> param_cstrings{};
nvrtcProgram prog;
cudaDeviceProp device_prop;
std::string cc = "30";
cudaError_t e = cudaGetDeviceProperties(&device_prop, 0);
int major, minor;
cudaError_t e1 = cudaDeviceGetAttribute(&major, cudaDevAttrComputeCapabilityMajor, 0);
cudaError_t e2 = cudaDeviceGetAttribute(&minor, cudaDevAttrComputeCapabilityMinor, 0);
if (e == cudaSuccess) {
cc = std::to_string(device_prop.major) + std::to_string(device_prop.minor);
if (e1 == cudaSuccess && e2 == cudaSuccess) {
cc = std::to_string(major) + std::to_string(minor);
} else {
LOG(WARNING) << "cannot detect compute capability from your device, "
<< "fall back to compute_30.";
......
......@@ -26,6 +26,7 @@
#include <dmlc/thread_local.h>
#include <tvm/runtime/registry.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include "cuda_common.h"
......@@ -73,9 +74,10 @@ class CUDADeviceAPI final : public DeviceAPI {
return;
}
case kDeviceName: {
cudaDeviceProp props;
CUDA_CALL(cudaGetDeviceProperties(&props, ctx.device_id));
*rv = std::string(props.name);
std::string name(256, 0);
CUDA_DRIVER_CALL(cuDeviceGetName(&name[0], name.size(), ctx.device_id));
name.resize(strlen(name.c_str()));
*rv = std::move(name);
return;
}
case kMaxClockRate: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment