Skip to content

Commit 0dfb50a

Browse files
committed
WIP
1 parent de573db commit 0dfb50a

File tree

7 files changed

+190
-211
lines changed

7 files changed

+190
-211
lines changed

src/torchcodec/_core/BetaCudaDeviceInterface.cpp

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
// #include <cuda_runtime.h> // For cudaStreamSynchronize
1919

2020
// Include dynamic loader for interface
21-
#include "src/torchcodec/_core/NVCUVIDDynamicLoader.h"
21+
#include "src/torchcodec/_core/NVCUVIDRuntimeLoader.h"
2222

2323
// Include NVCUVID headers for types
2424
#include "src/torchcodec/_core/nvcuvid_include/cuviddec.h"
@@ -161,11 +161,6 @@ bool nativeNVDECSupport(const SharedAVCodecContext& codecContext) {
161161
// Return true iff the input video stream is supported by our NVDEC
162162
// implementation.
163163

164-
// First check if NVCUVID is available
165-
if (!isNVCUVIDLoaded()) {
166-
return false;
167-
}
168-
169164
auto codecType = validateCodecSupport(codecContext->codec_id);
170165
if (!codecType.has_value()) {
171166
return false;
@@ -234,13 +229,7 @@ BetaCudaDeviceInterface::BetaCudaDeviceInterface(const torch::Device& device)
234229
initializeCudaContextWithPytorch(device_);
235230
nppCtx_ = getNppStreamContext(device_);
236231

237-
// Try to load NVCUVID - if this fails, we'll use CPU fallback
238-
if (!initNVCUVID()) {
239-
// NVCUVID loading failed, we'll create CPU fallback during initialize()
240-
nvcuvidAvailable_ = false;
241-
} else {
242-
nvcuvidAvailable_ = true;
243-
}
232+
nvcuvidAvailable_ = loadNVCUVIDLibrary();
244233
}
245234

246235
BetaCudaDeviceInterface::~BetaCudaDeviceInterface() {
@@ -719,15 +708,16 @@ void BetaCudaDeviceInterface::convertAVFrameToFrameOutput(
719708
}
720709

721710
std::string BetaCudaDeviceInterface::getDetails() {
711+
std::string details = "Beta CUDA Device Interface.";
722712
if (cpuFallback_) {
713+
details += " Using CPU fallback.";
723714
if (!nvcuvidAvailable_) {
724-
return "Beta CUDA Device Interface. Using CPU fallback (NVCUVID not available - install NVIDIA drivers with NVDEC support).";
725-
} else {
726-
return "Beta CUDA Device Interface. Using CPU fallback.";
715+
details += " NVCUVID not available!";
727716
}
728717
} else {
729-
return "Beta CUDA Device Interface. Using NVDEC.";
718+
details += " Using NVDEC.";
730719
}
720+
return details;
731721
}
732722

733723
} // namespace facebook::torchcodec

src/torchcodec/_core/BetaCudaDeviceInterface.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ class BetaCudaDeviceInterface : public DeviceInterface {
9898
UniqueNppContext nppCtx_;
9999

100100
std::unique_ptr<DeviceInterface> cpuFallback_;
101-
102-
// Track whether NVCUVID was successfully loaded
103101
bool nvcuvidAvailable_ = false;
104102
};
105103

src/torchcodec/_core/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function(make_torchcodec_libraries
9999
)
100100

101101
if(ENABLE_CUDA)
102-
list(APPEND core_sources CudaDeviceInterface.cpp BetaCudaDeviceInterface.cpp NVDECCache.cpp CUDACommon.cpp NVCUVIDDynamicWrappers.cpp)
102+
list(APPEND core_sources CudaDeviceInterface.cpp BetaCudaDeviceInterface.cpp NVDECCache.cpp CUDACommon.cpp NVCUVIDRuntimeLoader.cpp)
103103
endif()
104104

105105
set(core_library_dependencies

src/torchcodec/_core/NVCUVIDDynamicWrappers.cpp

Lines changed: 0 additions & 187 deletions
This file was deleted.

0 commit comments

Comments
 (0)