@@ -146,31 +146,39 @@ CUDAJpegEncoder::~CUDAJpegEncoder() {
146
146
// We run cudaGetDeviceCount as a dummy to test if the CUDA runtime is still
147
147
// initialized. If it is not, we can skip the rest of this function as it is
148
148
// unsafe to execute.
149
+
150
+ std::cout << " CUDAJpegEncoder dtor: checking if CUDA runtime is still alive"
151
+ << std::endl;
149
152
int deviceCount = 0 ;
150
153
cudaError_t error = cudaGetDeviceCount (&deviceCount);
151
- if (error != cudaSuccess)
154
+ if (error != cudaSuccess) {
155
+ std::cout << " CUDAJpegEncoder dtor: CUDA already shut down" << std::endl;
152
156
return ; // CUDA runtime has already shut down. There's nothing we can do
153
157
// now.
158
+ }
154
159
155
160
nvjpegStatus_t status;
156
161
162
+ std::cout << " CUDAJpegEncoder dtor: 1" << std::endl;
163
+
157
164
status = nvjpegEncoderParamsDestroy (nv_enc_params);
158
165
TORCH_CHECK (
159
166
status == NVJPEG_STATUS_SUCCESS,
160
167
" Failed to destroy nvjpeg encoder params: " ,
161
168
status);
162
-
169
+ std::cout << " CUDAJpegEncoder dtor: 2 " << std::endl;
163
170
status = nvjpegEncoderStateDestroy (nv_enc_state);
164
171
TORCH_CHECK (
165
172
status == NVJPEG_STATUS_SUCCESS,
166
173
" Failed to destroy nvjpeg encoder state: " ,
167
174
status);
168
175
169
176
cudaStreamSynchronize (stream);
170
-
177
+ std::cout << " CUDAJpegEncoder dtor: 3 " << std::endl;
171
178
status = nvjpegDestroy (nvjpeg_handle);
172
179
TORCH_CHECK (
173
180
status == NVJPEG_STATUS_SUCCESS, " nvjpegDestroy failed: " , status);
181
+ std::cout << " CUDAJpegEncoder dtor: 4" << std::endl;
174
182
}
175
183
176
184
torch::Tensor CUDAJpegEncoder::encode_jpeg (const torch::Tensor& src_image) {
0 commit comments