Skip to content

Commit f3c8a72

Browse files
committed
add dtor log messages
1 parent df60183 commit f3c8a72

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

torchvision/csrc/io/image/cuda/encode_jpegs_cuda.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,31 +146,40 @@ CUDAJpegEncoder::~CUDAJpegEncoder() {
146146
// We run cudaGetDeviceCount as a dummy to test if the CUDA runtime is still
147147
// initialized. If it is not, we can skip the rest of this function as it is
148148
// unsafe to execute.
149+
150+
std::cout << "CUDAJpegEncoder dtor: checking if CUDA runtime is still alive"
151+
<< std::endl;
149152
int deviceCount = 0;
150153
cudaError_t error = cudaGetDeviceCount(&deviceCount);
151-
if (error != cudaSuccess)
154+
if (error != cudaSuccess) {
155+
std::cout << "CUDAJpegEncoder dtor: CUDA already shut down" << std::endl;
152156
return; // CUDA runtime has already shut down. There's nothing we can do
153157
// now.
158+
}
154159

155160
nvjpegStatus_t status;
156161

162+
std::cout << "CUDAJpegEncoder dtor: 1" << std::endl;
163+
157164
status = nvjpegEncoderParamsDestroy(nv_enc_params);
165+
std::cout << "status: " << status << std::endl;
158166
TORCH_CHECK(
159167
status == NVJPEG_STATUS_SUCCESS,
160168
"Failed to destroy nvjpeg encoder params: ",
161169
status);
162-
170+
std::cout << "CUDAJpegEncoder dtor: 2" << std::endl;
163171
status = nvjpegEncoderStateDestroy(nv_enc_state);
164172
TORCH_CHECK(
165173
status == NVJPEG_STATUS_SUCCESS,
166174
"Failed to destroy nvjpeg encoder state: ",
167175
status);
168176

169177
cudaStreamSynchronize(stream);
170-
178+
std::cout << "CUDAJpegEncoder dtor: 3" << std::endl;
171179
status = nvjpegDestroy(nvjpeg_handle);
172180
TORCH_CHECK(
173181
status == NVJPEG_STATUS_SUCCESS, "nvjpegDestroy failed: ", status);
182+
std::cout << "CUDAJpegEncoder dtor: 4" << std::endl;
174183
}
175184

176185
torch::Tensor CUDAJpegEncoder::encode_jpeg(const torch::Tensor& src_image) {

0 commit comments

Comments
 (0)