| 75 | } |
| 76 | |
| 77 | DeviceProperties GetLocalGPUInfo(PlatformGpuId platform_gpu_id) { |
| 78 | DeviceProperties device; |
| 79 | device.set_type("GPU"); |
| 80 | |
| 81 | #if GOOGLE_CUDA |
| 82 | cudaDeviceProp properties; |
| 83 | cudaError_t error = |
| 84 | cudaGetDeviceProperties(&properties, platform_gpu_id.value()); |
| 85 | if (error != cudaSuccess) { |
| 86 | device.set_type("UNKNOWN"); |
| 87 | LOG(ERROR) << "Failed to get device properties, error code: " << error; |
| 88 | return device; |
| 89 | } |
| 90 | |
| 91 | device.set_vendor("NVIDIA"); |
| 92 | device.set_model(properties.name); |
| 93 | device.set_frequency(properties.clockRate * 1e-3); |
| 94 | device.set_num_cores(properties.multiProcessorCount); |
| 95 | device.set_num_registers(properties.regsPerMultiprocessor); |
| 96 | // For compute capability less than 5, l1 cache size is configurable to |
| 97 | // either 16 KB or 48 KB. We use the initial configuration 16 KB here. For |
| 98 | // compute capability larger or equal to 5, l1 cache (unified with texture |
| 99 | // cache) size is 24 KB. This number may need to be updated for future |
| 100 | // compute capabilities. |
| 101 | device.set_l1_cache_size((properties.major < 5) ? 16 * 1024 : 24 * 1024); |
| 102 | device.set_l2_cache_size(properties.l2CacheSize); |
| 103 | device.set_l3_cache_size(0); |
| 104 | device.set_shared_memory_size_per_multiprocessor( |
| 105 | properties.sharedMemPerMultiprocessor); |
| 106 | device.set_memory_size(properties.totalGlobalMem); |
| 107 | // 8 is the number of bits per byte. 2 is accounted for |
| 108 | // double data rate (DDR). |
| 109 | device.set_bandwidth(properties.memoryBusWidth / 8 * |
| 110 | properties.memoryClockRate * 2); |
| 111 | |
| 112 | (*device.mutable_environment())["architecture"] = |
| 113 | strings::StrCat(properties.major, ".", properties.minor); |
| 114 | (*device.mutable_environment())["cuda"] = strings::StrCat(CUDA_VERSION); |
| 115 | (*device.mutable_environment())["cudnn"] = strings::StrCat(CUDNN_VERSION); |
| 116 | |
| 117 | #elif TENSORFLOW_USE_ROCM |
| 118 | hipDeviceProp_t properties; |
| 119 | hipError_t error = |
| 120 | hipGetDeviceProperties(&properties, platform_gpu_id.value()); |
| 121 | if (error != hipSuccess) { |
| 122 | device.set_type("UNKNOWN"); |
| 123 | LOG(ERROR) << "Failed to get device properties, error code: " << error; |
| 124 | return device; |
| 125 | } |
| 126 | |
| 127 | // ROCM TODO review if numbers here are valid |
| 128 | device.set_vendor("Advanced Micro Devices, Inc"); |
| 129 | device.set_model(properties.name); |
| 130 | device.set_frequency(properties.clockRate * 1e-3); |
| 131 | device.set_num_cores(properties.multiProcessorCount); |
| 132 | device.set_num_registers(properties.regsPerBlock); |
| 133 | device.set_l1_cache_size(16 * 1024); |
| 134 | device.set_l2_cache_size(properties.l2CacheSize); |