Skip to content

Commit

Permalink
Do not compile CUDA helper for CPU build (pytorch#3657)
Browse files Browse the repository at this point in the history
  • Loading branch information
mthrok authored Oct 13, 2023
1 parent fa78fb6 commit 0b6ca28
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/libtorio/ffmpeg/stream_reader/stream_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ AVCodecContextPtr alloc_codec_context(
return AVCodecContextPtr(codec_ctx);
}

#ifdef USE_CUDA
const AVCodecHWConfig* get_cuda_config(const AVCodec* codec) {
for (int i = 0;; ++i) {
const AVCodecHWConfig* config = avcodec_get_hw_config(codec, i);
Expand Down Expand Up @@ -80,6 +81,7 @@ enum AVPixelFormat get_hw_format(
TORCH_WARN("Failed to get HW surface format.");
return AV_PIX_FMT_NONE;
}
#endif // USE_CUDA

AVBufferRef* get_hw_frames_ctx(AVCodecContext* codec_ctx) {
AVBufferRef* p = av_hwframe_ctx_alloc(codec_ctx->hw_device_ctx);
Expand Down
2 changes: 2 additions & 0 deletions src/libtorio/ffmpeg/stream_writer/encode_process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ void configure_video_codec_ctx(
}
}

#ifdef USE_CUDA
void configure_hw_accel(AVCodecContext* ctx, const std::string& hw_accel) {
torch::Device device{hw_accel};
TORCH_CHECK(
Expand Down Expand Up @@ -570,6 +571,7 @@ void configure_hw_accel(AVCodecContext* ctx, const std::string& hw_accel) {
"Failed to initialize CUDA frame context: ",
av_err2string(ret));
}
#endif // USE_CUDA

////////////////////////////////////////////////////////////////////////////////
// AVStream
Expand Down

0 comments on commit 0b6ca28

Please sign in to comment.