cudart
- paddle.cuda. cudart ( ) [source]
-
Retrieves the CUDA runtime API module.
This function initializes the CUDA runtime environment if it is not already initialized and returns the CUDA runtime API module (_cudart). The CUDA runtime API module provides access to various CUDA runtime functions.
- Parameters
-
None –
- Returns
-
The CUDA runtime API module (_cudart).
- Return type
-
module
Examples
>>> >>> 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 ======")
