Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 0 additions & 64 deletions .github/workflows/test_linux_cuda.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
cmake_minimum_required(VERSION 3.18)
project(TorchCodec)

option(ENABLE_CUDA "Enable CUDA decoding using NVDEC" OFF)
option(ENABLE_NVTX "Enable NVTX annotations for profiling" OFF)

add_subdirectory(src/torchcodec/decoders/_core)


Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,3 @@ guide](CONTRIBUTING.md) for more details.
## License

TorchCodec is released under the [BSD 3 license](./LICENSE).


If you are building with ENABLE_CUDA and/or ENABLE_NVTX please review
[Nvidia licenses](https://docs.nvidia.com/cuda/eula/index.html).
7 changes: 3 additions & 4 deletions benchmarks/decoders/BenchmarkDecodersMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void runNDecodeIterations(
decoder->addVideoStreamDecoder(-1);
for (double pts : ptsList) {
decoder->setCursorPtsInSeconds(pts);
torch::Tensor tensor = decoder->getNextDecodedOutputNoDemux().frame;
torch::Tensor tensor = decoder->getNextDecodedOutput().frame;
}
if (i + 1 == warmupIterations) {
start = std::chrono::high_resolution_clock::now();
Expand Down Expand Up @@ -95,7 +95,7 @@ void runNdecodeIterationsGrabbingConsecutiveFrames(
VideoDecoder::createFromFilePath(videoPath);
decoder->addVideoStreamDecoder(-1);
for (int j = 0; j < consecutiveFrameCount; ++j) {
torch::Tensor tensor = decoder->getNextDecodedOutputNoDemux().frame;
torch::Tensor tensor = decoder->getNextDecodedOutput().frame;
}
if (i + 1 == warmupIterations) {
start = std::chrono::high_resolution_clock::now();
Expand Down Expand Up @@ -145,8 +145,7 @@ void runNDecodeIterationsWithCustomOps(
/*height=*/std::nullopt,
/*thread_count=*/std::nullopt,
/*dimension_order=*/std::nullopt,
/*stream_index=*/std::nullopt,
/*device_string=*/std::nullopt);
/*stream_index=*/std::nullopt);

for (double pts : ptsList) {
seekFrameOp.call(decoderTensor, pts);
Expand Down
144 changes: 0 additions & 144 deletions benchmarks/decoders/gpu_benchmark.py

This file was deleted.

11 changes: 0 additions & 11 deletions examples/basic_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,3 @@ def plot(frames: torch.Tensor, title : Optional[str] = None):
# %%
plot(frame_at_2_seconds.data, "Frame displayed at 2 seconds")
plot(first_two_seconds.data, "Frames displayed during [0, 2) seconds")

# %%
# Using a CUDA GPU to accelerate decoding
# ---------------------------------------
#
# If you have a CUDA GPU that has NVDEC, you can decode on the GPU.
if torch.cuda.is_available():
cuda_decoder = SimpleVideoDecoder(raw_video_bytes, device="cuda:0")
cuda_frame = cuda_decoder.get_frame_displayed_at(seconds=2)
print(cuda_frame.data.device) # should be cuda:0
plot(cuda_frame.data.to("cpu"), "Frame displayed at 2 seconds on CUDA")
4 changes: 0 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,12 @@ def _build_all_extensions_with_cmake(self):
torch_dir = Path(torch.utils.cmake_prefix_path) / "Torch"
cmake_build_type = os.environ.get("CMAKE_BUILD_TYPE", "Release")
python_version = sys.version_info
enable_cuda = os.environ.get("ENABLE_CUDA", "")
enable_nvtx = os.environ.get("ENABLE_NVTX", "")
cmake_args = [
f"-DCMAKE_INSTALL_PREFIX={self._install_prefix}",
f"-DTorch_DIR={torch_dir}",
"-DCMAKE_VERBOSE_MAKEFILE=ON",
f"-DCMAKE_BUILD_TYPE={cmake_build_type}",
f"-DPYTHON_VERSION={python_version.major}.{python_version.minor}",
f"-DENABLE_CUDA={enable_cuda}",
f"-DENABLE_NVTX={enable_nvtx}",
]

Path(self.build_temp).mkdir(parents=True, exist_ok=True)
Expand Down
2 changes: 0 additions & 2 deletions src/torchcodec/_samplers/video_clip_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class VideoTooShortException(Exception):
@dataclass
class DecoderArgs:
num_threads: int = 0
device: torch.device = torch.device("cpu")


@dataclass
Expand Down Expand Up @@ -164,7 +163,6 @@ def forward(self, video_data: Tensor) -> Union[List[Any]]:
width=target_width,
height=target_height,
num_threads=self.decoder_args.num_threads,
device_string=str(self.decoder_args.device),
)

clips: List[Any] = []
Expand Down
39 changes: 3 additions & 36 deletions src/torchcodec/decoders/_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,6 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Torch REQUIRED)

if(ENABLE_CUDA)
find_package(CUDA REQUIRED)

if(ENABLE_NVTX)
# We only need CPM for NVTX:
# https://github.com/NVIDIA/NVTX#cmake
file(
DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.38.3/CPM.cmake
${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake
EXPECTED_HASH SHA256=cc155ce02e7945e7b8967ddfaff0b050e958a723ef7aad3766d368940cb15494
)
include(${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake)
CPMAddPackage(
NAME NVTX
GITHUB_REPOSITORY NVIDIA/NVTX
GIT_TAG v3.1.0-c-cpp
GIT_SHALLOW TRUE)
endif()
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
find_package(Python3 ${PYTHON_VERSION} EXACT COMPONENTS Development)

Expand All @@ -41,12 +19,6 @@ function(make_torchcodec_library library_name ffmpeg_target)
)
add_library(${library_name} SHARED ${sources})
set_property(TARGET ${library_name} PROPERTY CXX_STANDARD 17)
if(ENABLE_CUDA)
target_compile_definitions(${library_name} PRIVATE ENABLE_CUDA=1)
endif()
if(ENABLE_NVTX)
target_compile_definitions(${library_name} PRIVATE ENABLE_NVTX=1)
endif()

target_include_directories(
${library_name}
Expand All @@ -56,17 +28,12 @@ function(make_torchcodec_library library_name ffmpeg_target)
${Python3_INCLUDE_DIRS}
)

set(NEEDED_LIBRARIES ${ffmpeg_target} ${TORCH_LIBRARIES} ${Python3_LIBRARIES})
if(ENABLE_CUDA)
list(APPEND NEEDED_LIBRARIES ${CUDA_CUDA_LIBRARY} ${CUDA_nppi_LIBRARY} ${CUDA_nppicc_LIBRARY} )
endif()
if(ENABLE_NVTX)
list(APPEND NEEDED_LIBRARIES nvtx3-cpp)
endif()
target_link_libraries(
${library_name}
PUBLIC
${NEEDED_LIBRARIES}
${ffmpeg_target}
${TORCH_LIBRARIES}
${Python3_LIBRARIES}
)

# We already set the library_name to be libtorchcodecN, so we don't want
Expand Down
2 changes: 0 additions & 2 deletions src/torchcodec/decoders/_core/FFMPEGCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ using UniqueAVFilterInOut = std::unique_ptr<
Deleterp<AVFilterInOut, void, avfilter_inout_free>>;
using UniqueAVIOContext = std::
unique_ptr<AVIOContext, Deleterp<AVIOContext, void, avio_context_free>>;
using UniqueAVBufferRef =
std::unique_ptr<AVBufferRef, Deleterp<AVBufferRef, void, av_buffer_unref>>;

// av_find_best_stream is not const-correct before commit:
// https://github.com/FFmpeg/FFmpeg/commit/46dac8cf3d250184ab4247809bc03f60e14f4c0c
Expand Down
Loading