# Disable PTX JIT Compilation

**URL:** <https://forums.developer.nvidia.com/t/disable-ptx-jit-compilation/264400>\
**Category:** CUDA Programming and Performance\
**Created:** [August 25, 2023, 10:59am UTC](https://forums.developer.nvidia.com/t/disable-ptx-jit-compilation/264400 "2023-08-25T10:59:50Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abdopensky](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Abdopensky](https://forums.developer.nvidia.com/u/Abdopensky)\
**Post date:** [August 25, 2023, 10:59am UTC](https://forums.developer.nvidia.com/t/disable-ptx-jit-compilation/264400/1 "2023-08-25T10:59:50Z")

</div>

![image](https://global.discourse-cdn.com/nvidia/original/4X/f/6/4/f6443f355fda41ac02600f8578b77419a3e0cb18.png)  
Hello folks,

I am having hard times to disable the PTX JIT compilation of my code as i am forcing CUDA\_DISABLE\_PTX\_JIT to 1 on Windows Environment variables (See on the image).

Please can you help ?

Thanks

Abdoulaye

---

<div class="post-metadata">

**Author:** ![njuffa](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@njuffa](https://forums.developer.nvidia.com/u/njuffa)\
**Post date:** [August 25, 2023, 11:07am UTC](https://forums.developer.nvidia.com/t/disable-ptx-jit-compilation/264400/2 "2023-08-25T11:07:23Z")

</div>

Set this environment variable:

```auto
CUDA_DISABLE_PTX_JIT=1

```

There is the relevant section of the CUDA Programming Guide:

> **[CUDA C++ Programming Guide](https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#env-vars)**
>
> The programming guide to the CUDA model and interface.

---

<div class="post-metadata">

**Author:** ![Abdopensky](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Abdopensky](https://forums.developer.nvidia.com/u/Abdopensky)\
**Post date:** [August 25, 2023, 11:07am UTC](https://forums.developer.nvidia.com/t/disable-ptx-jit-compilation/264400/3 "2023-08-25T11:07:50Z")

</div>

That’s what I did as shown on screenshot

---

<div class="post-metadata">

**Author:** ![njuffa](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@njuffa](https://forums.developer.nvidia.com/u/njuffa)\
**Post date:** [August 25, 2023, 11:12am UTC](https://forums.developer.nvidia.com/t/disable-ptx-jit-compilation/264400/4 "2023-08-25T11:12:55Z")

</div>

You **wrote** about `CUDA_CACHE_DISABLE`, not `CUDA_DISABLE_PTX_JIT`. Can you be more specific about the issue than “I am having hard times”?

Have you double checked that you are setting `CUDA_DISABLE_PTX_JIT=1` in the environment relevant to the execution of your application? For example, you could call `getenv()` in your application to inspect the environment the application operates in.

You could also try setting `CUDA_DISABLE_JIT=1`.

---

<div class="post-metadata">

**Author:** ![Abdopensky](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Abdopensky](https://forums.developer.nvidia.com/u/Abdopensky)\
**Post date:** [August 25, 2023, 11:31am UTC](https://forums.developer.nvidia.com/t/disable-ptx-jit-compilation/264400/6 "2023-08-25T11:31:37Z")

</div>

Sorry I mistyped the keyword.

I did this and getenv() is also giving “1”. My problem is whenever I am using Visual Studio Debug Mode, my program will have a 30 seconds delay at the line where I am supposed to create a CUDA context for using CuSolver. So I suspected that the PTX JIT compilation was the culprit.

Also, when using the Nsight Compute, the PTX code will appear along with the SASS. I only want to show SASS for intellectual property purpose.

Thanks

Abdoulaye

---

<div class="post-metadata">

**Author:** ![njuffa](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@njuffa](https://forums.developer.nvidia.com/u/njuffa)\
**Post date:** [August 25, 2023, 11:41am UTC](https://forums.developer.nvidia.com/t/disable-ptx-jit-compilation/264400/7 "2023-08-25T11:41:34Z")

</div>

> [@Abdopensky](#):
>
> So I suspected that the PTX JIT compilation was the culprit.

Unless there are other differences in the compilation flags for debug and release builds, I would expect any noticeable JIT overhead to affect _both_ debug and release builds. Because debug builds are unoptimized, I would further expect any JIT overhead that does occur to be slightly lower for debug builds. So attributing delay seen when starting up the debug build to JIT overhead seems questionable.

> [@Abdopensky](#):
>
> Also, when using the Nsight Compute, the PTX code will appear along with the SASS

Build the binary without including PTX for those situations. Depositing only SASS in the fat binary is a choice readily available to the programmer. See documentation of the `-gencode` switch. This will also be a good experiment in investigating the mysterious 30 second delay. Without PTX in the fat binary, JIT compilation is impossible. That still leaves the possibility of the presence of PTX in libraries you do not control. Outside of special circumstance I would libraries to be compiled such that SASS is include for all supported GPU architectures, meaing PTX JIT compilation never comes into play.

---

<div class="post-metadata">

**Author:** ![Abdopensky](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Abdopensky](https://forums.developer.nvidia.com/u/Abdopensky)\
**Post date:** [August 25, 2023, 11:47am UTC](https://forums.developer.nvidia.com/t/disable-ptx-jit-compilation/264400/8 "2023-08-25T11:47:59Z")

</div>

> Build the binary without including PTX for those situations. Depositing only SASS in the fat binary is a choice readily available to the programmer. See documentation of the `-gencode` switch. This will also be a good experiment in investigating the mysterious 30 second delay. Without PTX in the fat binary, JIT compilation is impossible.

My configuration is arch=compute\_86,code=sm\_86

---

<div class="post-metadata">

**Author:** ![njuffa](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@njuffa](https://forums.developer.nvidia.com/u/njuffa)\
**Post date:** [August 25, 2023, 11:49am UTC](https://forums.developer.nvidia.com/t/disable-ptx-jit-compilation/264400/9 "2023-08-25T11:49:38Z")

</div>

Use `cuobjdump --dump-sass` and `cuobjdump --dump-ptx` to examine what SASS and what PTX were deposited into your binary.

---

<div class="post-metadata">

**Author:** ![Abdopensky](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Abdopensky](https://forums.developer.nvidia.com/u/Abdopensky)\
**Post date:** [August 25, 2023, 12:19pm UTC](https://forums.developer.nvidia.com/t/disable-ptx-jit-compilation/264400/10 "2023-08-25T12:19:38Z")

</div>

> [@njuffa](#):
>
> cuda-objdump --dump-sass

Well I was able to run both commands and for PTX, I can see my functions/variables symbols listed. So, do you know how to disable the PTX ?

---

<div class="post-metadata">

**Author:** ![Abdopensky](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Abdopensky](https://forums.developer.nvidia.com/u/Abdopensky)\
**Post date:** [August 25, 2023, 12:32pm UTC](https://forums.developer.nvidia.com/t/disable-ptx-jit-compilation/264400/11 "2023-08-25T12:32:23Z")

</div>

Wait ! On my visual studio script, I am seeing -gencode=arch=compute\_86,code="sm\_86,compute\_86.

But the command i put on option is compute\_86,sm\_86. Is it right?

---

<div class="post-metadata">

**Author:** ![njuffa](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@njuffa](https://forums.developer.nvidia.com/u/njuffa)\
**Post date:** [August 25, 2023, 12:35pm UTC](https://forums.developer.nvidia.com/t/disable-ptx-jit-compilation/264400/12 "2023-08-25T12:35:01Z")

</div>

With

> [@Abdopensky](#):
>
> -gencode arch=compute\_86,code=sm\_86

alone, there should be **no** PTX embedded in the fat binary. Just to be sure, I compiled a small test application in two ways:

```auto
nvcc -o zcopy.exe -arch=sm_30 zcopy.cu
nvcc -o zcopy.exe -gencode arch=compute_30,code=sm_30 zcopy.cu

```

Using `cuobjdump` to inspect, I find that the binary produced by the first build contains PTX and SASS for `sm_30`, while the binary produced by the second build contains SASS for `sm_30` and an empty PTX section. This is exactly as expected.

So if you are seeing PTX code in the fat binary, there must be other `-gencode` instances besides `-gencode arch=compute_86,code=sm_86`.

> [@Abdopensky](#):
>
> I am seeing -gencode=arch=compute\_86,code="sm\_86,compute\_86

The `compute_86` part is what causes PTX to be deposited into the fat binary. Take a look at the documentation for `-gencode`: `sm_XX` deposits SASS for a real GPU architecture, `compute_XX` deposits PTX for a virtual GPU architecture. Your build specifies to do both.

---

<div class="post-metadata">

**Author:** ![Abdopensky](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Abdopensky](https://forums.developer.nvidia.com/u/Abdopensky)\
**Post date:** [August 25, 2023, 12:39pm UTC](https://forums.developer.nvidia.com/t/disable-ptx-jit-compilation/264400/13 "2023-08-25T12:39:19Z")

</div>

![image](https://global.discourse-cdn.com/nvidia/original/4X/5/b/8/5b89d9ca008da6ab615d914810bec30510866fae.png)

Well I think i found the problem. But i don’t know why it’s compiling "-gencode=arch=compute\_86,code=“sm\_86,compute\_86” instead of "-gencode=arch=compute\_86,code=“sm\_86”

---

<div class="post-metadata">

**Author:** ![Abdopensky](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Abdopensky](https://forums.developer.nvidia.com/u/Abdopensky)\
**Post date:** [August 25, 2023, 12:41pm UTC](https://forums.developer.nvidia.com/t/disable-ptx-jit-compilation/264400/14 "2023-08-25T12:41:58Z")

</div>

Ok I got you now !! I just simply need to put sm\_86. Thank you so much for your help :)

---

<div class="post-metadata">

**Author:** ![Abdopensky](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Abdopensky](https://forums.developer.nvidia.com/u/Abdopensky)\
**Post date:** [August 25, 2023, 1:04pm UTC](https://forums.developer.nvidia.com/t/disable-ptx-jit-compilation/264400/15 "2023-08-25T13:04:41Z")

</div>

@njuffa please a little help. Can you tell me what i put exactly on this Visual Studio input ? I tried sm\_86 then sm\_86,sm\_86 and none of them are working. Thanks

---

<div class="post-metadata">

**Author:** ![Abdopensky](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Abdopensky](https://forums.developer.nvidia.com/u/Abdopensky)\
**Post date:** [August 25, 2023, 2:38pm UTC](https://forums.developer.nvidia.com/t/disable-ptx-jit-compilation/264400/16 "2023-08-25T14:38:41Z")

</div>

@njuffa i think that I finally found the issue. It seems that the PTX JIT is only activated when running under CUDA Debugging (Next-Gen). Whilst when running from Start button (VS2022), the JIT are deactivated.

---

<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:** [September 8, 2023, 2:39pm UTC](https://forums.developer.nvidia.com/t/disable-ptx-jit-compilation/264400/17 "2023-09-08T14:39:00Z")

</div>

Closed on September 8, 2023, 2:39pm UTC

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