cuda.bindings._v2.driver.graph_add_mem_alloc_node#

cuda.bindings._v2.driver.graph_add_mem_alloc_node(
intptr_t h_graph,
dependencies,
size_t num_dependencies,
node_params,
) → intptr_t#

Creates an allocation node and adds it to a graph.

Creates a new allocation node and adds it to h_graph with num_dependencies dependencies specified via dependencies and arguments specified in node_params. It is possible for num_dependencies to be 0, in which case the node will be placed at the root of the graph. dependencies may not have any duplicate entries. A handle to the new node will be returned in ph_graph_node. When cuGraphAddMemAllocNode creates an allocation node, it returns the address of the allocation in node_params.dptr. The allocation’s address remains fixed across instantiations and launches. If the allocation is freed in the same graph, by creating a free node using cuGraphAddMemFreeNode, the allocation can be accessed by nodes ordered after the allocation node but before the free node. These allocations cannot be freed outside the owning graph, and they can only be freed once in the owning graph. If the allocation is not freed in the same graph, then it can be accessed not only by nodes in the graph which are ordered after the allocation node, but also by stream operations ordered after the graph’s execution but before the allocation is freed. Allocations which are not freed in the same graph can be freed by:.

  • passing the allocation to cuMemFreeAsync or cuMemFree;.

  • launching a graph with a free node for that allocation; or.

  • specifying CUDA_GRAPH_INSTANTIATE_FLAG_AUTO_FREE_ON_LAUNCH during instantiation, which makes each launch behave as though it called cuMemFreeAsync for every unfreed allocation.

It is not possible to free an allocation in both the owning graph and another graph. If the allocation is freed in the same graph, a free node cannot be added to another graph. If the allocation is freed in another graph, a free node can no longer be added to the owning graph. The following restrictions apply to graphs which contain allocation and/or memory free nodes:.

  • Nodes and edges of the graph cannot be deleted.

  • The graph can only be used in a child node if the ownership is moved to the parent.

  • Only one instantiation of the graph may exist at any point in time.

  • The graph cannot be cloned.

Parameters:
  • h_graph (intptr_t) – Graph to which to add the node.

  • dependencies (object) –

    Dependencies of the node. It can be:

    • an int as the pointer address to the array, or

    • a Python sequence of ints (as pointer addresses).

  • num_dependencies (size_t) – Number of dependencies.

  • node_params (intptr_t) – Parameters for the node.

Returns:

Returns newly created node.

Return type:

intptr_t

See also

cuGraphAddMemAllocNode