CUDA Device Query

Introduction

The CUDA runtime API cudaGetDeviceProperties is our companion in CUDA programming to find the information of the current CUDA device so that some CUDA kernel parameters can be adjusted for optimization at runtime.

The NVIDIA device query application is built on top of the CUDA runtime API cudaGetDeviceProperties. It helps the first-time users who are unfamiliar with the device to have some idea about the device.

Docker Device Query

The NVIDIA device query application is wrapped in a Dockerfile and it supports both AMD64 and ARM64 platforms.

Dockerfile

The NVIDIA device query application is part of the NVIDIA CUDA samples on GitHub.

device-query.Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Change the CUDA version if necessary.
FROM nvcr.io/nvidia/cuda:11.6.2-devel-ubuntu20.04

ENV DEBIAN_FRONTEND=noninteractive

# Install package dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
wget && \
apt-get clean

RUN cd /tmp && \
wget https://github.com/NVIDIA/cuda-samples/archive/refs/tags/v11.6.tar.gz && \
tar xvzf v11.6.tar.gz && \
cd cuda-samples-11.6/Samples/1_Utilities/deviceQuery && \
make && \
cp deviceQuery /bin && \
rm -rf /tmp/*

CMD ["deviceQuery"]

Notice that using CUDA base or runtime Docker images as the base image will not work as they don’t come with the NVCC compiler.

Build Docker Image

To build the Docker image locally, please run the following command.

1
$ docker build -f device-query.Dockerfile -t device-query:11.6.2 .

I have also cross-platform built the application for both AMD64 and ARM64 platforms and uploaded to DockerHub.

1
2
3
$ sudo apt-get install -y binfmt-support qemu-user-static
$ docker buildx create --use --name cross-platform-build
$ docker buildx build -f device-query.Dockerfile --platform linux/amd64,linux/arm64 -t leimao/device-query:11.6.2 --push .

The user can just pull the Docker images from DockerHub without building.

1
2
$ docker pull leimao/device-query:11.6.2
$ docker tag leimao/device-query:11.6.2 device-query:11.6.2

Run Docker Container

To run the device query via the Docker container, please run the following command.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
$ docker run --gpus all device-query:0.0.1
deviceQuery Starting...

CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "NVIDIA GeForce RTX 3090"
CUDA Driver Version / Runtime Version 11.6 / 11.6
CUDA Capability Major/Minor version number: 8.6
Total amount of global memory: 24246 MBytes (25423577088 bytes)
(082) Multiprocessors, (128) CUDA Cores/MP: 10496 CUDA Cores
GPU Max Clock rate: 1695 MHz (1.70 GHz)
Memory Clock rate: 9751 Mhz
Memory Bus Width: 384-bit
L2 Cache Size: 6291456 bytes
Maximum Texture Dimension Size (x,y,z) 1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
Maximum Layered 1D Texture Size, (num) layers 1D=(32768), 2048 layers
Maximum Layered 2D Texture Size, (num) layers 2D=(32768, 32768), 2048 layers
Total amount of constant memory: 65536 bytes
Total amount of shared memory per block: 49152 bytes
Total shared memory per multiprocessor: 102400 bytes
Total number of registers available per block: 65536
Warp size: 32
Maximum number of threads per multiprocessor: 1536
Maximum number of threads per block: 1024
Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
Max dimension size of a grid size (x,y,z): (2147483647, 65535, 65535)
Maximum memory pitch: 2147483647 bytes
Texture alignment: 512 bytes
Concurrent copy and kernel execution: Yes with 2 copy engine(s)
Run time limit on kernels: Yes
Integrated GPU sharing Host Memory: No
Support host page-locked memory mapping: Yes
Alignment requirement for Surfaces: Yes
Device has ECC support: Disabled
Device supports Unified Addressing (UVA): Yes
Device supports Managed Memory: Yes
Device supports Compute Preemption: Yes
Supports Cooperative Kernel Launch: Yes
Supports MultiDevice Co-op Kernel Launch: Yes
Device PCI Domain ID / Bus ID / location ID: 0 / 1 / 0
Compute Mode:
< Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 11.6, CUDA Runtime Version = 11.6, NumDevs = 1
Result = PASS

References

Author

Lei Mao

Posted on

09-08-2022

Updated on

09-08-2022

Licensed under


Comments