Skip to main content

cudaInitDevice

Function cudaInitDevice 

Source
pub unsafe extern "C" fn cudaInitDevice(
    device: c_int,
    deviceFlags: c_uint,
    flags: c_uint,
) -> cudaError_t
Expand description

Initialize device to be used for GPU executions.

This function will initialize the CUDA Runtime structures and primary context on device when called, but the context will not be made current to device.

When cudaInitDeviceFlagsAreValid is set in flags, deviceFlags are applied to the requested device. The values of deviceFlags match those of the flags parameters in cudaSetDeviceFlags. The effect may be verified by cudaGetDeviceFlags.

This function will return an error if the device is in cudaComputeMode::cudaComputeModeExclusiveProcess and is occupied by another process or if the device is in cudaComputeMode::cudaComputeModeProhibited.

Note that this function may also return error codes from previous, asynchronous launches.

Note that this function may also return cudaError_t::CUDA_ERROR_NOT_INITIALIZED, cudaErrorInsufficientDriver or cudaError_t::CUDA_ERROR_NO_DEVICE if this call tries to initialize internal CUDA RT state.

Note that as specified by cudaStreamAddCallback no CUDA function may be called from callback. cudaError_t::CUDA_ERROR_NOT_PERMITTED may, but is not guaranteed to, be returned as a diagnostic in such case.

§Parameters

  • device: Device on which the runtime will initialize itself.
  • deviceFlags: Parameters for device operation.
  • flags: Flags for controlling the device initialization.

§Return value

See also: cudaGetDeviceCount, cudaGetDevice, cudaGetDeviceProperties, cudaChooseDevice, cudaSetDevice, cuCtxSetCurrent.