Device

The Device abstract represents any hardware device with memory and compuation units. All [Tensor operations](tensor.html) are scheduled by the resident device for execution. Tensor memory is also managed by the device’s memory manager. Therefore, optimization of memory and execution are implemented in the Device class.

Specific devices

Currently, SINGA has three Device implmentations,

  1. CudaGPU for an Nvidia GPU card which runs Cuda code

  2. CppCPU for a CPU which runs Cpp code

  3. OpenclGPU for a GPU card which runs OpenCL code

Python API

This script includes Device class and its subclasses for python users to call singa::Device and its methods.

TODO(wangwei) implement py CudaGPU class.

singa.device.create_cuda_gpus(num)

Create a list of CudaGPU devices.

Parameters

num (int) – number of device to create.

Returns

a list of swig converted CudaGPU devices.

singa.device.create_cuda_gpus_on(device_ids)

Create a list of CudaGPU devices.

Parameters

device_ids (list) – a list of GPU card IDs.

Returns

a list of swig converted CudaGPU devices.

singa.device.get_default_device()

Get the default host device which is a CppCPU device

The following code provides examples of creating devices:

from singa import device
cuda = device.create_cuda_gpu_on(0)  # use GPU card of ID 0
host = device.get_default_device()  # get the default host device (a CppCPU)
ary1 = device.create_cuda_gpus(2)  # create 2 devices, starting from ID 0
ary2 = device.create_cuda_gpus([0,2])  # create 2 devices on ID 0 and 2

CPP API