@@ -146,31 +146,40 @@ 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);
165
+ std::cout << " status: " << status << std::endl;
158
166
TORCH_CHECK (
159
167
status == NVJPEG_STATUS_SUCCESS,
160
168
" Failed to destroy nvjpeg encoder params: " ,
161
169
status);
162
-
170
+ std::cout << " CUDAJpegEncoder dtor: 2 " << std::endl;
163
171
status = nvjpegEncoderStateDestroy (nv_enc_state);
164
172
TORCH_CHECK (
165
173
status == NVJPEG_STATUS_SUCCESS,
166
174
" Failed to destroy nvjpeg encoder state: " ,
167
175
status);
168
176
169
177
cudaStreamSynchronize (stream);
170
-
178
+ std::cout << " CUDAJpegEncoder dtor: 3 " << std::endl;
171
179
status = nvjpegDestroy (nvjpeg_handle);
172
180
TORCH_CHECK (
173
181
status == NVJPEG_STATUS_SUCCESS, " nvjpegDestroy failed: " , status);
182
+ std::cout << " CUDAJpegEncoder dtor: 4" << std::endl;
174
183
}
175
184
176
185
torch::Tensor CUDAJpegEncoder::encode_jpeg (const torch::Tensor& src_image) {
0 commit comments