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
propstructure. The created allocation will not have any device or host mappings. The generic memoryhandlefor the allocation can be mapped to the address space of calling process viacuMemMap. This handle cannot be transmitted directly to other processes (seecuMemExportToShareableHandle). On Windows, the caller must also pass an LPSECURITYATTRIBUTE inpropto be associated with this handle which limits or allows access to this handle for a recipient process (seeCUmemAllocationProp.win32HandleMetaDatafor more). Thesizeof this allocation must be a multiple of the the value given viacuMemGetAllocationGranularitywith theCU_MEM_ALLOC_GRANULARITY_MINIMUMflag. To create a CPU allocation that doesn’t target any specific NUMA nodes, applications must setCUmemAllocationProp.CUmemLocation.typetoCU_MEM_LOCATION_TYPE_HOST.CUmemAllocationProp::CUmemLocation::id is ignored for HOST allocations. HOST allocations are not IPC capable andCUmemAllocationProp.requestedHandleTypesmust be 0, any other value will result inCUDA_ERROR_INVALID_VALUE. To create a CPU allocation targeting a specific host NUMA node, applications must setCUmemAllocationProp.CUmemLocation.typetoCU_MEM_LOCATION_TYPE_HOST_NUMAandCUmemAllocationProp::CUmemLocation::id must specify the NUMA ID of the CPU. On systems where NUMA is not availableCUmemAllocationProp::CUmemLocation::id must be set to 0. SpecifyingCU_MEM_LOCATION_TYPE_HOST_NUMA_CURRENTas theCUmemLocation.typewill result inCUDA_ERROR_INVALID_VALUE. SpecifyingCU_MEM_LOCATION_TYPE_DEVICE_LOCALITY_DOMAINas theCUmemLocation.typewill 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 alsocuDeviceGetAttributewith the attributeCU_DEVICE_ATTRIBUTE_LOCALITY_DOMAIN_COUNT. Applications that intend to useCU_MEM_HANDLE_TYPE_FABRICbased memory sharing must ensure: (1)nvidia-caps-imex-channelscharacter 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. IfCUmemAllocationProp.allocFlags.usagecontainsCU_MEM_CREATE_USAGE_TILE_POOLflag then the memory allocation is intended only to be used as backing tile pool for sparse CUDA arrays and sparse CUDA mipmapped arrays. (seecuMemMapArrayAsync).- 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_DOMAINand localityDomainId 0 is equivalent to a full-device allocation created withCU_MEM_LOCATION_TYPE_DEVICE. The resulting allocation will be of typeCU_MEM_LOCATION_TYPE_DEVICE.See also
cuMemCreate