cudart

paddle.cuda. cudart ( ) [源代码]

获取 CUDA 运行时 API 模块(_cudart),CUDA 运行时 API 模块提供对各种 CUDA 运行时函数的访问。

返回

以 Python 模块形式返回 CUDA 运行时 API 模块(_cudart)。

代码示例

>>> import paddle
>>> from paddle.cuda import cudart, check_error
>>> import os
>>> os.environ['CUDA_PROFILE'] = '1'
>>> def perform_cuda_operations_with_streams():
>>>     stream = paddle.cuda.Stream()
>>>     with paddle.cuda.stream(stream):
>>>         x = paddle.randn((100, 100), device='cuda')
>>>         y = paddle.randn((100, 100), device='cuda')
>>>         z = paddle.mul(x, y)
>>>     return z
>>> paddle.cuda.synchronize()
>>> # print("====== Start nsys profiling ======")
>>> check_error(cudart().cudaProfilerStart())
>>> paddle.core.nvprof_start()
>>> paddle.core.nvprof_nvtx_push("Test")
>>> result = perform_cuda_operations_with_streams()
>>> paddle.core.nvprof_nvtx_pop()
>>> # print("CUDA operations completed.")
>>> check_error(paddle.cuda.cudart().cudaProfilerStop())
>>> # print("====== End nsys profiling ======")