MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / device

Method device

tensorpack/utils/nvml.py:185–206  ·  view source on GitHub ↗

Get a specific GPU device Args: idx: index of device Returns: NvidiaDevice: single GPU device

(self, idx)

Source from the content-addressed store, hash-verified

183 return [self.device(i) for i in range(self.num_devices())]
184
185 def device(self, idx):
186 """Get a specific GPU device
187
188 Args:
189 idx: index of device
190
191 Returns:
192 NvidiaDevice: single GPU device
193 """
194 num_dev = self.num_devices()
195 assert idx < num_dev, "Cannot obtain device {}: NVML only found {} devices.".format(idx, num_dev)
196
197 class GpuDevice(Structure):
198 pass
199
200 c_nvmlDevice_t = POINTER(GpuDevice)
201
202 c_index = c_uint(idx)
203 device = c_nvmlDevice_t()
204 _check_return(_NVML.get_function(
205 "nvmlDeviceGetHandleByIndex_v2")(c_index, byref(device)))
206 return NvidiaDevice(device)
207
208
209if __name__ == '__main__':

Callers 15

devicesMethod · 0.95
allreduce_gradsFunction · 0.80
aggregate_grads_colocateFunction · 0.80
allreduce_grads_naiveFunction · 0.80
pack_allMethod · 0.80
unpack_allMethod · 0.80
buildMethod · 0.80
buildMethod · 0.80
call_for_each_towerMethod · 0.80

Calls 5

num_devicesMethod · 0.95
_check_returnFunction · 0.85
NvidiaDeviceClass · 0.85
formatMethod · 0.80
get_functionMethod · 0.80

Tested by

no test coverage detected