Skip to content

Instantly share code, notes, and snippets.

@Xosrov
Created November 6, 2023 07:19
Show Gist options
  • Save Xosrov/093f2f623e90baf50ec5946bb39651c5 to your computer and use it in GitHub Desktop.
Save Xosrov/093f2f623e90baf50ec5946bb39651c5 to your computer and use it in GitHub Desktop.
Getting NVIDIA CUDA architecture and capability version with a Dockerfile

I suggest you read this first:
https://arnon.dk/matching-sm-architectures-arch-and-gencode-for-various-nvidia-cards/

An easy way to get all the details you need like CUDA version and compute capabilities (sm) for your graphics card, is to use this Docker image:

FROM nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04

# set up build dependencies
ENV	DEBIAN_FRONTEND=noninteractive
ENV PATH /usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH}
RUN apt-get update && apt-get install -y --no-install-recommends \
    g++ \
    gcc \
    nvidia-cuda-toolkit \
    make \
    git

RUN mkdir -p /code && \
    git clone --depth 1 https://github.com/NVIDIA/cuda-samples.git /code/cuda-samples && \
    cd /code/cuda-samples/Samples/1_Utilities/deviceQuery && \
    make

CMD ["/code/cuda-samples/Samples/1_Utilities/deviceQuery/deviceQuery"]

NOTE: make sure to update the NVIDIA image in the future.

This Dockerfile builds an example from NVIDIA itself, called deviceQuery, which prints very useful information for your specific hardware. After building this image, run it with the --gpus all tag and you should see information about your GPU.

@Xosrov
Copy link
Author

Xosrov commented Nov 6, 2023

Alternatively run nvidia-smi --query-gpu=compute_cap --format=csv,noheader | head -n 1
From here to get only capability :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment