Installation Verification
The following is the minimum startup example for running GPU tensor computation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | python3 - <<'PY' import ctypes import paddle print("load_libcuda", ctypes.CDLL("libcuda.so.1")._name) print("paddle_version", paddle.__version__) print("compiled_with_cuda", paddle.device.is_compiled_with_cuda()) print("device_count", paddle.device.cuda.device_count()) paddle.set_device("gpu:0") x = paddle.arange(6, dtype="float32").reshape([2, 3]) y = paddle.ones([3, 2], dtype="float32") z = paddle.matmul(x, y) + 1 paddle.device.synchronize() print("place", z.place) print("result", z.numpy().tolist()) PY |
The expected output is as follows.
1 2 3 4 5 6 | load_libcuda libcuda.so.1 paddle_version 3.3.0.dev20260319 compiled_with_cuda True device_count 1 place Place(gpu:0) result [[4.0, 4.0], [13.0, 13.0]] |
The pass criteria are as follows.
- Paddle is successfully imported.
- compiled_with_cuda is True.
- The value of device_count is greater than 0.
- The tensor runs on gpu:0.
- The GPU tensor calculation result is correct.
Parent topic: Installation Guide