File tree Expand file tree Collapse file tree 4 files changed +32
-0
lines changed
src/slave/containerizer/mesos/isolators/gpu Expand file tree Collapse file tree 4 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,11 @@ static Try<set<Gpu>> enumerateGpus(
9595 }
9696 }
9797
98+ Try<unsigned int > caps_major = nvml::systemGetCapsMajor ();
99+ if (caps_major.isError ()) {
100+ return Error (" Failed to get nvidia caps major: " + caps_major.error ());
101+ }
102+
98103 set<Gpu> gpus;
99104
100105 foreach (unsigned int index, indices) {
@@ -148,6 +153,7 @@ static Try<set<Gpu>> enumerateGpus(
148153 gpu.major = NVIDIA_MAJOR_DEVICE;
149154 gpu.minor = minor.get ();
150155 gpu.ismig = true ;
156+ gpu.caps_major = caps_major.get ();
151157 gpu.gi_minor = gi_minor.get ();
152158 gpu.ci_minor = ci_minor.get ();
153159
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ struct Gpu
4747
4848 // MIG support
4949 bool ismig;
50+ unsigned int caps_major;
5051 unsigned int gi_minor;
5152 unsigned int ci_minor;
5253};
Original file line number Diff line number Diff line change @@ -237,6 +237,30 @@ bool isAvailable()
237237}
238238
239239
240+ Try<unsigned int > systemGetCapsMajor ()
241+ {
242+ std::ifstream procfile (" /proc/devices" );
243+
244+ while (procfile) {
245+ string procline;
246+ std::getline (procfile, procline);
247+
248+ if (procline.find (" nvidia-caps" ) != std::string::npos) {
249+ unsigned int major;
250+
251+ try {
252+ major = std::stoi (procline);
253+ } catch (...) {
254+ return Error (" Could not parse nvidia-caps major from /proc/devices" );
255+ }
256+
257+ return major;
258+ }
259+ }
260+ return Error (" nvidia-caps not found in /proc/devices" );
261+ }
262+
263+
240264Try<string> systemGetDriverVersion ()
241265{
242266 if (nvml == nullptr ) {
Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ Try<Nothing> initialize();
5353// NVML wrapper functions. May be called after initializing
5454// the library.
5555Try<std::string> systemGetDriverVersion ();
56+ Try<unsigned int > systemGetCapsMajor ();
5657Try<unsigned int > deviceGetCount ();
5758Try<nvmlDevice_t> deviceGetHandleByIndex (unsigned int index);
5859Try<unsigned int > deviceGetMinorNumber (nvmlDevice_t handle);
You can’t perform that action at this time.
0 commit comments