Repository navigation
Description
Is this a duplicate?
- I confirmed there appear to be no duplicate issues for this bug and that I agree to the Code of Conduct
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 cleanExpected 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
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
github-actions commentedon Nov 20, 2025
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.
elstehle commentedon Nov 20, 2025
Thank you for sharing your observation, @lilohuang!
@bernhardmgruber, do you have more information or could you otherwise please take a look?
bernhardmgruber commentedon Nov 20, 2025
I have no additional information, but will have a look.
bernhardmgruber commentedon Nov 20, 2025
I just tried to run your reproducer on my workstation, where I have an RTX 5090, inside a git clone of CCCL using:
Driver Version: 580.95.05
On the
3.1.xbranch, I can see that when the program stops atgetchar(),nvidia-smishows:On the
3.2.xbranch, I can see that when the program stops atgetchar(),nvidia-smishows:Adding a bunch of
getchar(), I can see that the500MiBare allocated by the first call to:On the
3.2.xbranch, that's about it. On the3.1.xbranch, the call tothrust::transformcauses the remaining3800MiBto be allocated.bernhardmgruber commentedon Nov 20, 2025
I tried looking at a few nsys traces, but nothing obvious. The calls to
cudaMallocare tiny. And the total memory usage is 72B, which is exactly3 * 6 * sizeof(int), the storage of the three thrust vectors. On both branches.I am forced to believe the memory is allocated by the CUDA runtime.
bernhardmgruber commentedon Nov 20, 2025
In any case, the large allocation by
thrust::transformis 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.lilohuang commentedon Nov 21, 2025
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.
4 remaining items
bernhardmgruber commentedon Jan 5, 2026
Unfortunately no, because I am still not convinced that this is a bug on our end.
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_bulkis::cuda::ptx::space_clusterinstead of::cuda::ptx::space_shared?[Backport to 3.1] Use `cp_async_bulk(space_shared,...)` when available (
bernhardmgruber commentedon Jan 15, 2026
We could finally identify the root cause of the allocation.
cp_async_bulkto state space::cuda::ptx::space_clusteron sm120 cannot be handled as efficiently as sm100, which is why using::cuda::ptx::space_sharedis 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 ;)
lilohuang commentedon Jan 19, 2026
@bernhardmgruber Thank you for looking into the details and providing a fix!
lilohuang commentedon Feb 5, 2026
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.
bernhardmgruber commentedon Feb 5, 2026
Correct. It only requires PTX ISA 8.6, which is available starting with CTK 12.8.
aswins-alt commentedon Feb 6, 2026
@bernhardmgruber @lilohuang This what i can confirm for RTX6000PRO:
lilohuang commentedon Feb 7, 2026
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.
lilohuang commentedon Feb 7, 2026
@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.
[main.cu]
[Makefile]
aswins-alt commentedon Feb 7, 2026
@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.
lilohuang commentedon Feb 8, 2026
@aswins-alt Glad to have that confirmed—thanks!