Device代表一个有内存和计算单元的硬件设备。所有的Tensor操作都由常驻设备安排执行的,Tensor内存也由设备的内存管理器管理。因此,需要在Device类中实现内存和执行的优化。
目前,SINGA支持三种设备:
下面的代码提供了创建设备的例子:
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