cuda.bindings.utils.get_ptx_ver

cuda.bindings.utils.get_ptx_ver(ptx: str) str

Extract the PTX ISA version string from PTX source code.

Parameters:

ptx (str) – The PTX assembly source code as a string.

Returns:

The PTX ISA version string, e.g., “8.8”.

Return type:

str

Raises:

ValueError – If the .version directive is not found in the PTX source.

Examples

>>> ptx = r'''
... .version 8.8
... .target sm_86
... .address_size 64
...
... .visible .entry test_kernel()
... {
...     ret;
... }
... '''
>>> get_ptx_ver(ptx)
'8.8'