MCPcopy Create free account
hub / github.com/colmap/colmap / FindBestCudaDevice

Function FindBestCudaDevice

src/colmap/util/cuda.cc:60–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60int FindBestCudaDevice() {
61 const int num_devices = GetNumCudaDevices();
62 THROW_CHECK_GT(num_devices, 0) << "No CUDA devices available";
63 std::vector<cudaDeviceProp> all_devices(num_devices);
64 std::vector<int> indices(num_devices);
65 for (int id = 0; id < num_devices; ++id) {
66 indices[id] = id;
67 cudaGetDeviceProperties(&all_devices[id], id);
68 }
69 std::sort(indices.begin(), indices.end(), [&](int a, int b) {
70 return CompareCudaDevice(all_devices[a], all_devices[b]);
71 });
72 const int selected = indices[0];
73 VLOG(2) << "Found " << num_devices << " CUDA device(s), "
74 << "selected device " << selected << " with name "
75 << all_devices[selected].name;
76 return selected;
77}
78
79void SetBestCudaDevice(const int gpu_index) {
80 const int num_cuda_devices = GetNumCudaDevices();

Callers 2

SolveMethod · 0.85
SetBestCudaDeviceFunction · 0.85

Calls 4

GetNumCudaDevicesFunction · 0.85
CompareCudaDeviceFunction · 0.85
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected