AI::MXNet::Context - A device context.
This class governs the device context of AI::MXNet::NDArray objects.
use AI::MXNet qw(mx); print nd->array([[1,2],[3,4]], ctx => mx->cpu)->aspdl; my $arr_gpu = nd->random->uniform(shape => [10, 10], ctx => mx->gpu(0));
Constructing a context. Parameters ---------- device_type : {'cpu', 'gpu'} or Context. String representing the device type device_id : int (default=0) The device id of the device, needed for GPU
Returns a CPU context. Parameters ---------- device_id : int, optional The device id of the device. device_id is not needed for CPU. This is included to make interface compatible with GPU. Returns ------- context : AI::MXNet::Context The corresponding CPU context.
Returns a CPU pinned memory context. Copying from CPU pinned memory to GPU is faster than from normal CPU memory. Parameters ---------- device_id : int, optional The device id of the device. `device_id` is not needed for CPU. This is included to make interface compatible with GPU. Returns ------- context : Context The corresponding CPU pinned memory context.
Returns a GPU context. Parameters ---------- device_id : int, optional Returns ------- context : AI::MXNet::Context The corresponding GPU context.
Returns the current context. Returns ------- $default_ctx : AI::MXNet::Context
Query CUDA for the number of GPUs present. Raises ------ Will raise an exception on any CUDA error. Returns ------- count : int The number of GPUs.
Query CUDA for the free and total bytes of GPU global memory. Parameters ---------- $device_id=0 : int, optional The device id of the GPU device. Raises ------ Will raise an exception on any CUDA error. Returns ------- ($free, $total) : (int, int) Free and total memory in bytes.
To install AI::MXNet, copy and paste the appropriate command in to your terminal.
cpanm
cpanm AI::MXNet
CPAN shell
perl -MCPAN -e shell install AI::MXNet
For more information on module installation, please visit the detailed CPAN module installation guide.