cuda.bindings._v2.driver.mem_create#

cuda.bindings._v2.driver.mem_create(size_t size, prop, unsigned long long flags) → uint64_t#

Create a CUDA memory handle representing a memory allocation of a given size described by the given properties.

This creates a memory allocation on the target device specified through the prop structure. The created allocation will not have any device or host mappings. The generic memory handle for the allocation can be mapped to the address space of calling process via cuMemMap. This handle cannot be transmitted directly to other processes (see cuMemExportToShareableHandle). On Windows, the caller must also pass an LPSECURITYATTRIBUTE in prop to be associated with this handle which limits or allows access to this handle for a recipient process (see CUmemAllocationProp.win32HandleMetaData for more). The size of this allocation must be a multiple of the the value given via cuMemGetAllocationGranularity with the CU_MEM_ALLOC_GRANULARITY_MINIMUM flag. To create a CPU allocation that doesn’t target any specific NUMA nodes, applications must set CUmemAllocationProp.CUmemLocation.type to CU_MEM_LOCATION_TYPE_HOST. CUmemAllocationProp::CUmemLocation::id is ignored for HOST allocations. HOST allocations are not IPC capable and CUmemAllocationProp.requestedHandleTypes must be 0, any other value will result in CUDA_ERROR_INVALID_VALUE. To create a CPU allocation targeting a specific host NUMA node, applications must set CUmemAllocationProp.CUmemLocation.type to CU_MEM_LOCATION_TYPE_HOST_NUMA and CUmemAllocationProp::CUmemLocation::id must specify the NUMA ID of the CPU. On systems where NUMA is not available CUmemAllocationProp::CUmemLocation::id must be set to 0. Specifying CU_MEM_LOCATION_TYPE_HOST_NUMA_CURRENT as the CUmemLocation.type will result in CUDA_ERROR_INVALID_VALUE. Specifying CU_MEM_LOCATION_TYPE_DEVICE_LOCALITY_DOMAIN as the CUmemLocation.type will localize the allocation to the specified locality domain. CUmemAllocationProp::CUmemLocation::localized.deviceId must specify the device ID. CUmemAllocationProp::CUmemLocation::localized.localityDomainId must specify the locality domain ID. The locality domain ID must be a valid locality domain ID for the specified device. See also cuDeviceGetAttribute with the attribute CU_DEVICE_ATTRIBUTE_LOCALITY_DOMAIN_COUNT. Applications that intend to use CU_MEM_HANDLE_TYPE_FABRIC based memory sharing must ensure: (1) nvidia-caps-imex-channels character device is created by the driver and is listed under /proc/devices (2) have at least one IMEX channel file accessible by the user launching the application. When exporter and importer CUDA processes have been granted access to the same IMEX channel, they can securely share memory. The IMEX channel security model works on a per user basis. Which means all processes under a user can share memory if the user has access to a valid IMEX channel. When multi-user isolation is desired, a separate IMEX channel is required for each user. These channel files exist in /dev/nvidia-caps-imex-channels/channel* and can be created using standard OS native calls like mknod on Linux. For example: To create channel0 with the major number from /proc/devices users can execute the following command: mknod /dev/nvidia-caps-imex-channels/channel0 c <major number> 0. If CUmemAllocationProp.allocFlags.usage contains CU_MEM_CREATE_USAGE_TILE_POOL flag then the memory allocation is intended only to be used as backing tile pool for sparse CUDA arrays and sparse CUDA mipmapped arrays. (see cuMemMapArrayAsync).

Parameters:
  • size (size_t) – Size of the allocation requested.

  • prop (intptr_t) – Properties of the allocation to create.

  • flags (unsigned long long) – flags for future use, must be zero now.

Returns:

Value of handle returned. All operations on this

allocation are to be performed using this handle.

Return type:

uint64_t

Note

On devices with a single locality domain, CU_MEM_LOCATION_TYPE_DEVICE_LOCALITY_DOMAIN and localityDomainId 0 is equivalent to a full-device allocation created with CU_MEM_LOCATION_TYPE_DEVICE. The resulting allocation will be of type CU_MEM_LOCATION_TYPE_DEVICE.

See also

cuMemCreate