Skip to content

[BUG]: Unexpected high GPU memory consumption (~4 GB) after calling thrust::transform on RTX PRO 6000 Blackwell #6708

Closed

Description

@lilohuang

Is this a duplicate?

Type of Bug

Performance

Component

Thrust

Describe the bug

The standalone bug reproducer below demonstrates the issue I observed on the RTX PRO 6000 Blackwell Server Edition. In this example, the GPU memory allocation size is relatively small. However, after calling thrust::transform and before the process terminates, checking GPU memory usage with nvidia-smi shows more than 4 GB being occupied for an unknown reason. If I change the NVCC compilation flag from
-gencode arch=compute_120,code=sm_120
to
-gencode arch=compute_80,code=sm_120
the issue disappears.

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|    0   N/A  N/A            2458      C   ./main                                 4532MiB |
+-----------------------------------------------------------------------------------------+

I suspect this behavior is related to TMA (Tensor Memory Accelerator) usage when it is available. Notably, this issue does not occur on H100 GPUs.

How to Reproduce

[main.cu]

#include <thrust/transform.h>
#include <thrust/functional.h>
#include <thrust/execution_policy.h>
#include <thrust/device_vector.h>
#include <iostream>

int main() {
   std::cout << "THRUST_VERSION: " << THRUST_VERSION << std::endl;

   // Host input arrays
   int h_input1[6] = {-5, 0, 2, 3, 2, 4};
   int h_input2[6] = {3, 6, -2, 1, 2, 3};

   // Device vectors
   thrust::device_vector<int> d_input1(h_input1, h_input1 + 6);
   thrust::device_vector<int> d_input2(h_input2, h_input2 + 6);
   thrust::device_vector<int> d_output(6);

   // Operation
   cuda::std::plus<int> op;

   // Perform transform on GPU
   thrust::transform(thrust::device,
                     d_input1.begin(), d_input1.end(),
                     d_input2.begin(),
                     d_output.begin(),
                     op);

   // Copy result back to host
   int h_output[6];
   thrust::copy(d_output.begin(), d_output.end(), h_output);

   // Print result
   std::cout << "Result: ";
   for (int i = 0; i < 6; i++) {
      std::cout << h_output[i] << " ";
   }
   std::cout << std::endl;
   std::cout << "Press Enter to exit..." << std::endl;
   getchar();
   std::cout << "Exiting." << std::endl;
   return 0;
}

[Makefile]

.RECIPEPREFIX := >

CC             := /usr/local/gcc-12.3.0/bin/gcc
CXX            := /usr/local/gcc-12.3.0/bin/g++
CUDA_PATH      := /usr/local/cuda/cuda-12.9
CCCL_ROOT      := /opt/cccl-3.1.4
THRUST_INC     := $(CCCL_ROOT)/thrust
CUB_INC        := $(CCCL_ROOT)/cub
LIBCUDACXX_INC := $(CCCL_ROOT)/libcudacxx/include

NVCC     := $(CUDA_PATH)/bin/nvcc
HOST_CXX := $(CXX)

CXXFLAGS := -O3 -std=c++17

COMMON_INCLUDES := \
  -I$(THRUST_INC) \
  -I$(CUB_INC) \
  -I$(LIBCUDACXX_INC)

CUDA_INCLUDES := \
  -isystem $(CUDA_PATH)/include

ALL_INCLUDES := $(COMMON_INCLUDES) $(CUDA_INCLUDES)

NVCCFLAGS := -ccbin $(HOST_CXX) -O3 -std=c++17 --extended-lambda
NVCCFLAGS += -gencode arch=compute_120,code=sm_120
NVCCFLAGS += -lcudart_static -lpthread -ldl
CXXFLAGS  += $(ALL_INCLUDES)

default: all

all: main

main: main.o
> $(NVCC) $(NVCCFLAGS) $^ -o $@

main.o: main.cu
> $(NVCC) $(NVCCFLAGS) $(ALL_INCLUDES) -c $< -o $@

clean:
> rm -rf *.o main

.PHONY: default all clean

Expected behavior

The GPU memory consumption should not noticeably increase after calling thrust::transform.

Reproduction link

No response

Operating System

SUSE Linux Enterprise Server 15 SP5

nvidia-smi output

Wed Nov 19 23:03:05 2025
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 570.195.03             Driver Version: 570.195.03     CUDA Version: 12.8     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA RTX PRO 6000 Blac...    On  |   00000000:03:00.0 Off |                    0 |
| N/A   31C    P0             85W /  600W |    4541MiB /  97887MiB |      0%      Default |
|                                         |                        |             Disabled |
+-----------------------------------------+------------------------+----------------------+
|   1  NVIDIA RTX PRO 6000 Blac...    On  |   00000000:04:00.0 Off |                    0 |
| N/A   28C    P8             34W /  600W |       3MiB /  97887MiB |      0%      Default |
|                                         |                        |             Disabled |
+-----------------------------------------+------------------------+----------------------+
|   2  NVIDIA RTX PRO 6000 Blac...    On  |   00000000:64:00.0 Off |                    0 |
| N/A   28C    P8             33W /  600W |       3MiB /  97887MiB |      0%      Default |
|                                         |                        |             Disabled |
+-----------------------------------------+------------------------+----------------------+
|   3  NVIDIA RTX PRO 6000 Blac...    On  |   00000000:65:00.0 Off |                    0 |
| N/A   28C    P8             34W /  600W |       3MiB /  97887MiB |      0%      Default |
|                                         |                        |             Disabled |
+-----------------------------------------+------------------------+----------------------+
|   4  NVIDIA RTX PRO 6000 Blac...    On  |   00000000:83:00.0 Off |                    0 |
| N/A   27C    P8             34W /  600W |       3MiB /  97887MiB |      0%      Default |
|                                         |                        |             Disabled |
+-----------------------------------------+------------------------+----------------------+
|   5  NVIDIA RTX PRO 6000 Blac...    On  |   00000000:84:00.0 Off |                    0 |
| N/A   28C    P8             33W /  600W |       3MiB /  97887MiB |      0%      Default |
|                                         |                        |             Disabled |
+-----------------------------------------+------------------------+----------------------+
|   6  NVIDIA RTX PRO 6000 Blac...    On  |   00000000:E3:00.0 Off |                    0 |
| N/A   28C    P8             32W /  600W |       3MiB /  97887MiB |      0%      Default |
|                                         |                        |             Disabled |
+-----------------------------------------+------------------------+----------------------+
|   7  NVIDIA RTX PRO 6000 Blac...    On  |   00000000:E4:00.0 Off |                    0 |
| N/A   27C    P8             33W /  600W |       3MiB /  97887MiB |      0%      Default |
|                                         |                        |             Disabled |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|    0   N/A  N/A            2458      C   ./main                                 4532MiB |
+-----------------------------------------------------------------------------------------+


NVCC version

% nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2025 NVIDIA Corporation
Built on Tue_May_27_02:21:03_PDT_2025
Cuda compilation tools, release 12.9, V12.9.86
Build cuda_12.9.r12.9/compiler.36037853_0

Activity

  1. added
    needs triage
    on Nov 20, 2025
  2. github-actions commented on Nov 20, 2025

    @github-actions
    Contributor

    Hi @lilohuang!

    Thanks for submitting this issue - the CCCL team has been notified and we'll get back to you as soon as we can!
    In the mean time, feel free to add any relevant information to this issue.

  3. elstehle commented on Nov 20, 2025

    @elstehle
    Contributor

    Thank you for sharing your observation, @lilohuang!

    @bernhardmgruber, do you have more information or could you otherwise please take a look?

  4. bernhardmgruber commented on Nov 20, 2025

    @bernhardmgruber
    Contributor

    @bernhardmgruber, do you have more information or could you otherwise please take a look?

    I have no additional information, but will have a look.

  5. removed
    needs triage
    on Nov 20, 2025
  6. bernhardmgruber commented on Nov 20, 2025

    @bernhardmgruber
    Contributor

    I just tried to run your reproducer on my workstation, where I have an RTX 5090, inside a git clone of CCCL using:

    cccl$ nvcc -Ithrust -Icub -Ilibcudacxx/include -arch=sm_120 ./mem.cu  && ./a.out
    
    cccl$ nvcc --version
    nvcc: NVIDIA (R) Cuda compiler driver
    Copyright (c) 2005-2025 NVIDIA Corporation
    Built on Wed_Aug_20_01:58:59_PM_PDT_2025
    Cuda compilation tools, release 13.0, V13.0.88
    Build cuda_13.0.r13.0/compiler.36424714_0
    

    Driver Version: 580.95.05

    On the 3.1.x branch, I can see that when the program stops at getchar(), nvidia-smi shows:

    |    0   N/A  N/A          595444      C   ./a.out                                4310MiB |
    

    On the 3.2.x branch, I can see that when the program stops at getchar(), nvidia-smi shows:

    |    0   N/A  N/A          597748      C   ./a.out                                 502MiB |
    

    Adding a bunch of getchar(), I can see that the 500MiB are allocated by the first call to:

    thrust::device_vector<int> d_input1(h_input1, h_input1 + 6);
    

    On the 3.2.x branch, that's about it. On the 3.1.x branch, the call to thrust::transform causes the remaining 3800MiB to be allocated.

  7. bernhardmgruber commented on Nov 20, 2025

    @bernhardmgruber
    Contributor

    I tried looking at a few nsys traces, but nothing obvious. The calls to cudaMalloc are tiny. And the total memory usage is 72B, which is exactly 3 * 6 * sizeof(int), the storage of the three thrust vectors. On both branches.

    Image

    I am forced to believe the memory is allocated by the CUDA runtime.

  8. bernhardmgruber commented on Nov 20, 2025

    @bernhardmgruber
    Contributor

    In any case, the large allocation by thrust::transform is gone in CCCL 3.2. I am curious though what caused it. There is nothing obvious in the git log between the two versions, except for the removal of includes of cooperative groups (but I readded the headers and there was no impact), and avoiding static shared memory and placing everything in dynamic shared memory.

  9. lilohuang commented on Nov 21, 2025

    @lilohuang
    Author

    Thank you, @bernhardmgruber. I also checked my program with the NSYS GPU memory profiler, and it appears that this issue has nothing to do with cudaMalloc (or cudaMallocAsync). This is why I suspect it may be related to the TMA (Tensor Memory Accelerator) usage or something similar within the CUDA runtime. It would be great to understand the root cause to prevent this issue from occurring. It would also be helpful if the CCCL team could backport the fix to 3.1.x. I will try rerunning the test with CCCL 3.2.0 as well.

  10. 4 remaining items

  11. bernhardmgruber commented on Jan 5, 2026

    @bernhardmgruber
    Contributor

    Any progress on fixing this issue?

    Unfortunately no, because I am still not convinced that this is a bug on our end.

    Perhaps the CCCL team could introduce a macro fence to block the TMA code path when the CUDA SDK version is 12.x?

    This will cause a major regression, because the TMA code path is a lot faster than the other code paths for some problem types.

    We could provide a custom macro to disable the TMA code path, but we also have other places where we use the same TMA call, for example in cub::DeviceMerge. And there are more to come. So I don't think a macro to disable TMA is a scalable solution.

    @ahendriksen do you have any insight on what's causing a 4GiB allocation on sm120 when the destination of a cp_async_bulk is ::cuda::ptx::space_cluster instead of ::cuda::ptx::space_shared?

  12. added theissue type on Jan 15, 2026
  13. bernhardmgruber commented on Jan 15, 2026

    @bernhardmgruber
    Contributor

    @ahendriksen do you have any insight on what's causing a 4GiB allocation on sm120 when the destination of a cp_async_bulk is ::cuda::ptx::space_cluster instead of ::cuda::ptx::space_shared?

    We could finally identify the root cause of the allocation. cp_async_bulk to state space ::cuda::ptx::space_cluster on sm120 cannot be handled as efficiently as sm100, which is why using ::cuda::ptx::space_shared is preferred and why we implemented this in #6362. The CUDA driver, when it loads a kernel with a bulk copy instruction to ::cuda::ptx::space_cluster, has to allocate auxiliary memory per GPU thread. On RTX PRO 6000, there are 188 SMs of 1536 threads and about 14.5KiB per thread are needed, which amounts to the 4.2GiB memory that nvidia-smi shows.

    So the memory increase you observe is by design. Please note that we implemented an improvement with #6362 that will ship in the CTK soon ;)

  14. moved this from Todo to Done in CCCLon Jan 15, 2026
  15. lilohuang commented on Jan 19, 2026

    @lilohuang
    Author

    @bernhardmgruber Thank you for looking into the details and providing a fix!

  16. lilohuang commented on Feb 5, 2026

    @lilohuang
    Author

    Here are some updates from my side. I downloaded CCCL 3.2.0 and recompiled my standalone bug reproducer, I observed that the unexpected GPU memory consumption (4GB) no longer occurs on an RTX PRO 6000 Blackwell GPU with CUDA driver 570.195.03 (12.8) with the CUDA 12.9 runtime.

    @bernhardmgruber, based on my testing results, I assume that your fix does not require the CUDA 13 SDK (driver or runtime). Please correct me if my understanding is incorrect. Thank you.

    [CCCL 3.1.0]
    +-----------------------------------------------------------------------------------------+
    | Processes:                                                                              |
    |  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
    |        ID   ID                                                               Usage      |
    |=========================================================================================|
    |    0   N/A  N/A           52408      C   ./main                                 4532MiB |
    +-----------------------------------------------------------------------------------------+
    
    [CCCL 3.2.0]
    +-----------------------------------------------------------------------------------------+
    | Processes:                                                                              |
    |  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
    |        ID   ID                                                               Usage      |
    |=========================================================================================|
    |    0   N/A  N/A           52771      C   ./main                                  556MiB |
    +-----------------------------------------------------------------------------------------+
    
  17. bernhardmgruber commented on Feb 5, 2026

    @bernhardmgruber
    Contributor

    @bernhardmgruber, based on my testing results, I assume that your fix does not require the CUDA 13 SDK (driver or runtime). Please correct me if my understanding is incorrect. Thank you.

    Correct. It only requires PTX ISA 8.6, which is available starting with CTK 12.8.

  18. aswins-alt commented on Feb 6, 2026

    @aswins-alt

    @bernhardmgruber @lilohuang This what i can confirm for RTX6000PRO:

    Driver CTK CCCL 314 CCCL 320
    12.8 12.8 YES YES
    12.8 12.9 NO NO
    12.9 12.8 YES YES
    12.9 12.9 NO NO
    13.0 12.8 YES YES
    13.0 12.9 NO NO
    13.0 13.0 NO YES
  19. lilohuang commented on Feb 7, 2026

    @lilohuang
    Author

    Thank you, @aswins-alt, for the comprehensive testing. Just to clarify, in your table, does "Yes" mean the bug still exists?

    I just noticed that the Makefile I provided had a few defects. I have updated a newer version to ensure it correctly overrides the default CCCL version shipped with the CUDA SDK. Additionally, I’ve modified main.cu to print the Thrust version, confirming it compiles with the expected version. Lastly, -lcudart_static has been added to ensure the executable uses the CUDA runtime library bundled with the CUDA SDK.

    I will continue testing with various CUDA drivers and SDKs while waiting for @bernhardmgruber’s response.

  20. lilohuang commented on Feb 7, 2026

    @lilohuang
    Author

    @bernhardmgruber and @aswins-alt Here are the test results using the updated Makefile and main.cu. I have also verified the Thrust version via STDOUT. The issue appears to be resolved; with CCCL 3.2.0, the bug is no longer reproducible. @aswins-alt, Could you please copy the updated Makefile and main.cu and verify this again on your end? I would like to apologize for any inconvenience caused.

    CTK 12.8 + CUDA driver 12.8 (570.124.06) + CCCL 3.1.4 =  Unexpected high GPU memory
    CTK 12.8 + CUDA driver 12.8 (570.124.06) + CCCL 3.2.0 =  No issue
    CTK 12.9 + CUDA driver 12.8 (570.124.06) + CCCL 3.1.4 =  Unexpected high GPU memory
    CTK 12.9 + CUDA driver 12.8 (570.124.06) + CCCL 3.2.0 =  No issue
    
    CTK 12.8 + CUDA driver 12.9 (575.57.08) + CCCL 3.1.4 =  Unexpected high GPU memory
    CTK 12.8 + CUDA driver 12.9 (575.57.08) + CCCL 3.2.0 =  No issue
    CTK 12.9 + CUDA driver 12.9 (575.57.08) + CCCL 3.1.4 =  Unexpected high GPU memory
    CTK 12.9 + CUDA driver 12.9 (575.57.08) + CCCL 3.2.0 =  No issue
    

    [main.cu]

    #include <thrust/transform.h>
    #include <thrust/functional.h>
    #include <thrust/execution_policy.h>
    #include <thrust/device_vector.h>
    #include <iostream>
    
    int main() {
       std::cout << "THRUST_VERSION: " << THRUST_VERSION << std::endl;
    
       // Host input arrays
       int h_input1[6] = {-5, 0, 2, 3, 2, 4};
       int h_input2[6] = {3, 6, -2, 1, 2, 3};
    
       // Device vectors
       thrust::device_vector<int> d_input1(h_input1, h_input1 + 6);
       thrust::device_vector<int> d_input2(h_input2, h_input2 + 6);
       thrust::device_vector<int> d_output(6);
    
       // Operation
       cuda::std::plus<int> op;
    
       // Perform transform on GPU
       thrust::transform(thrust::device,
                         d_input1.begin(), d_input1.end(),
                         d_input2.begin(),
                         d_output.begin(),
                         op);
    
       // Copy result back to host
       int h_output[6];
       thrust::copy(d_output.begin(), d_output.end(), h_output);
    
       // Print result
       std::cout << "Result: ";
       for (int i = 0; i < 6; i++) {
          std::cout << h_output[i] << " ";
       }
       std::cout << std::endl;
       std::cout << "Press Enter to exit..." << std::endl;
       getchar();
       std::cout << "Exiting." << std::endl;
       return 0;
    }

    [Makefile]

    .RECIPEPREFIX := >
    
    CC             := /usr/local/gcc-12.3.0/bin/gcc
    CXX            := /usr/local/gcc-12.3.0/bin/g++
    CUDA_PATH      := /usr/local/cuda/cuda-12.9
    CCCL_ROOT      := /opt/cccl-3.1.4
    THRUST_INC     := $(CCCL_ROOT)/thrust
    CUB_INC        := $(CCCL_ROOT)/cub
    LIBCUDACXX_INC := $(CCCL_ROOT)/libcudacxx/include
    
    NVCC     := $(CUDA_PATH)/bin/nvcc
    HOST_CXX := $(CXX)
    
    CXXFLAGS := -O3 -std=c++17
    
    COMMON_INCLUDES := \
      -I$(THRUST_INC) \
      -I$(CUB_INC) \
      -I$(LIBCUDACXX_INC)
    
    CUDA_INCLUDES := \
      -isystem $(CUDA_PATH)/include
    
    ALL_INCLUDES := $(COMMON_INCLUDES) $(CUDA_INCLUDES)
    
    NVCCFLAGS := -ccbin $(HOST_CXX) -O3 -std=c++17 --extended-lambda
    NVCCFLAGS += -gencode arch=compute_120,code=sm_120
    NVCCFLAGS += -lcudart_static -lpthread -ldl
    CXXFLAGS  += $(ALL_INCLUDES)
    
    default: all
    
    all: main
    
    main: main.o
    > $(NVCC) $(NVCCFLAGS) $^ -o $@
    
    main.o: main.cu
    > $(NVCC) $(NVCCFLAGS) $(ALL_INCLUDES) -c $< -o $@
    
    clean:
    > rm -rf *.o main
    
    .PHONY: default all clean
  21. aswins-alt commented on Feb 7, 2026

    @aswins-alt

    @lilohuang Thanks for the updated Makefile. I should have checked if the custom cccl was correctly being pulled when 12.8 + v314 was passing in my previous attempt.

    Here are the updated results. It confirms your experiments too.

     

    Driver CTK CCCL 314 CCCL 320
    12.8 (570.124) 12.8 NO YES
    12.8 (570.124) 12.9 NO YES
    12.9 (575.57) 12.8 NO YES
    12.9 (575.57) 12.9 NO YES
    13.0 (580.95) 12.8 NO YES
    13.0 (580.95) 12.9 NO YES
    13.0 (580.95) 13.0 NO YES
  22. lilohuang commented on Feb 8, 2026

    @lilohuang
    Author

    @aswins-alt Glad to have that confirmed—thanks!

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

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions