# Force a certain ptx version

**URL:** <https://forums.developer.nvidia.com/t/force-a-certain-ptx-version/200892>\
**Category:** CUDA Programming and Performance\
**Created:** [January 18, 2022, 6:38pm UTC](https://forums.developer.nvidia.com/t/force-a-certain-ptx-version/200892 "2022-01-18T18:38:52Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![TrailingStop](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@TrailingStop](https://forums.developer.nvidia.com/u/TrailingStop)\
**Post date:** [January 18, 2022, 6:38pm UTC](https://forums.developer.nvidia.com/t/force-a-certain-ptx-version/200892/1 "2022-01-18T18:38:52Z")

</div>

Hi,

is it possible to define the ptx version that nvrtcCompileProgram creates?

Thanks,  
Daniel

---

<div class="post-metadata">

**Author:** ![striker159](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@striker159](https://forums.developer.nvidia.com/u/striker159)\
**Post date:** [January 18, 2022, 7:37pm UTC](https://forums.developer.nvidia.com/t/force-a-certain-ptx-version/200892/2 "2022-01-18T19:37:34Z")

</div>

Did you check the documentation? [https://docs.nvidia.com/cuda/nvrtc/index.html#group\_\_options](https://docs.nvidia.com/cuda/nvrtc/index.html#group__options)

---

<div class="post-metadata">

**Author:** ![TrailingStop](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@TrailingStop](https://forums.developer.nvidia.com/u/TrailingStop)\
**Post date:** [January 18, 2022, 8:22pm UTC](https://forums.developer.nvidia.com/t/force-a-certain-ptx-version/200892/3 "2022-01-18T20:22:45Z")

</div>

Hi,

yes - I did. That is the reason why I’m asking here. I think you are pointing to the “compute/architecture” version which you can define by setting the --gpu-architecture value, but this is not what I asked. I’m looking for the version of the generated ptx file. The 11.6 cuda JIT compiler generates a ptx file of the version 7.6, but I want the compiler to generate a ptx file that is compatible to a different - lower - version.

---

<div class="post-metadata">

**Author:** ![striker159](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@striker159](https://forums.developer.nvidia.com/u/striker159)\
**Post date:** [January 18, 2022, 8:40pm UTC](https://forums.developer.nvidia.com/t/force-a-certain-ptx-version/200892/4 "2022-01-18T20:40:48Z")

</div>

Thank you for clarification. In that case I have misunderstood your question

---

<div class="post-metadata">

**Author:** ![Robert\_Crovella](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/robert_crovella/32/14043_2.png) [@Robert\_Crovella](https://forums.developer.nvidia.com/u/Robert_Crovella)\
**Post date:** [January 21, 2022, 1:01am UTC](https://forums.developer.nvidia.com/t/force-a-certain-ptx-version/200892/5 "2022-01-21T01:01:57Z")

</div>

No, its not possible. Anything you build with CUDA toolkit 11.6 requires a GPU driver on the target machine that supports CUDA 11.6. In such a situation, the ptx version will work. Likewise, anything built with an older CUDA toolkit will work on a target machine that has a GPU driver compatible with CUDA 11.6

Those are the compatibility scenarios, and in those cases the PTX version will not be an issue. There is no defined compatibility path for CUDA 11.6 to build things that are usable in machine that does not support CUDA 11.6, either by direct driver support or by the [compatibility library](https://docs.nvidia.com/deploy/cuda-compatibility/) method.

---

<div class="post-metadata">

**Author:** ![TrailingStop](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@TrailingStop](https://forums.developer.nvidia.com/u/TrailingStop)\
**Post date:** [January 21, 2022, 1:11am UTC](https://forums.developer.nvidia.com/t/force-a-certain-ptx-version/200892/6 "2022-01-21T01:11:40Z")

</div>

Hi- Yes, this was my question. Thanks a lot for the information.

---

<div class="post-metadata">

**Author:** ![TrailingStop](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@TrailingStop](https://forums.developer.nvidia.com/u/TrailingStop)\
**Post date:** [January 21, 2022, 9:24am UTC](https://forums.developer.nvidia.com/t/force-a-certain-ptx-version/200892/7 "2022-01-21T09:24:15Z")

</div>

I run still into an issue where I could need some help. In my application I like to be able to run the kernel on the customers configuration. I do not know it in advance, but I like to give best performance at the same time. In my application I use JIT compilation to be able to react on the customer computer configuration.

So assume that I have 3 customers:

1. 1070 with an old driver that allows cuda 10.2
2. 1070 with latest driver that allows cuda 11.6
3. 1050 Ti with almost new driver allowing cuda 11.5

If my understanding is correct I can get the best available cuda version calling:

```auto
int iCudaVersionInstalled;
nvmlReturn_t l_nError =nvmlSystemGetCudaDriverVersion( &iCudaVersionInstalled );

```

And I can get the compute version of the device ( cuDevice → cuda device id):

```auto
int nComputeMajor;
cuDeviceGetAttribute(&nComputeMajor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, cuDevice);

int nComputeMinor;
cuDeviceGetAttribute(&nComputeMinor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, cuDevice);

```

Is there any way, that my application can load the correct libraries at runtime (LoadLibrary) to support the customer configuration - independed from the installed cuda version? For example: I can load to support a cuda 11.2 environment the library “nvrtc64\_112\_0.dll” and get the entry points of the required functions. Or do I need to provide the customers with binaries compiled for each of these cuda version? One for 10.2, one for 11.6 and one for 11.5?

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![Robert\_Crovella](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/robert_crovella/32/14043_2.png) [@Robert\_Crovella](https://forums.developer.nvidia.com/u/Robert_Crovella)\
**Post date:** [January 21, 2022, 2:41pm UTC](https://forums.developer.nvidia.com/t/force-a-certain-ptx-version/200892/8 "2022-01-21T14:41:23Z")

</div>

The issue is the GPU driver installed on each customer’s machine, not the installed CUDA version.

The customer with the “old driver” will prevent you from using any CUDA tookit version or component version (eg. nvrtc library component) that comes from a newer CUDA toolkit version than what is supported by that old driver.

---

<div class="post-metadata">

**Author:** ![TrailingStop](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@TrailingStop](https://forums.developer.nvidia.com/u/TrailingStop)\
**Post date:** [January 21, 2022, 2:51pm UTC](https://forums.developer.nvidia.com/t/force-a-certain-ptx-version/200892/9 "2022-01-21T14:51:39Z")

</div>

Thanks for your fast reply. Yes, but what are my options for this situation? Do I need to create/compile binaries for each possible cuda version that I need because the customer do not want to update the driver? Or can I ‘somehow’ develop a generic binary that can react on the different cuda requirements (what I would prefer)?

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![Robert\_Crovella](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/robert_crovella/32/14043_2.png) [@Robert\_Crovella](https://forums.developer.nvidia.com/u/Robert_Crovella)\
**Post date:** [January 21, 2022, 3:00pm UTC](https://forums.developer.nvidia.com/t/force-a-certain-ptx-version/200892/10 "2022-01-21T15:00:06Z")

</div>

A typical option would be to

- determine what is the oldest driver version in your fleet or customer base (that you want to support)
- use a CUDA toolkit for development that is supported by that driver version
- build SASS for the GPUs recognized by that driver version (that you want to support)
- build PTX against the highest architecture supported by that driver version, to support all other/newer GPUs

The `makefile` system in the CUDA sample codes does “roughly” this.

You could also ship multiple binaries.  
You could also expect customers to update the GPU driver on older machines (indicate the lowest driver version you can support.)

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/system/32/68080_2.png) [@system](https://forums.developer.nvidia.com/u/system)\
**Post date:** [February 4, 2022, 3:00pm UTC](https://forums.developer.nvidia.com/t/force-a-certain-ptx-version/200892/11 "2022-02-04T15:00:44Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
