@@ -55,7 +55,8 @@ class VideoDecoder:
5555 decoding which is best if you are running a single instance of ``VideoDecoder``.
5656 Passing 0 lets FFmpeg decide on the number of threads.
5757 Default: 1.
58- device (str or torch.device, optional): The device to use for decoding. Default: "cpu".
58+ device (str or torch.device, optional): The device to use for decoding.
59+ If ``None`` (default), uses the current default device.
5960 If you pass a CUDA device, we recommend trying the "beta" CUDA
6061 backend which is faster! See :func:`~torchcodec.decoders.set_cuda_backend`.
6162 seek_mode (str, optional): Determines if frame access will be "exact" or
@@ -102,7 +103,7 @@ def __init__(
102103 stream_index : Optional [int ] = None ,
103104 dimension_order : Literal ["NCHW" , "NHWC" ] = "NCHW" ,
104105 num_ffmpeg_threads : int = 1 ,
105- device : Optional [Union [str , torch_device ]] = "cpu" ,
106+ device : Optional [Union [str , torch_device ]] = None ,
106107 seek_mode : Literal ["exact" , "approximate" ] = "exact" ,
107108 custom_frame_mappings : Optional [
108109 Union [str , bytes , io .RawIOBase , io .BufferedReader ]
@@ -143,7 +144,9 @@ def __init__(
143144 if num_ffmpeg_threads is None :
144145 raise ValueError (f"{ num_ffmpeg_threads = } should be an int." )
145146
146- if isinstance (device , torch_device ):
147+ if device is None :
148+ device = str (torch .get_default_device ())
149+ elif isinstance (device , torch_device ):
147150 device = str (device )
148151
149152 device_variant = _get_cuda_backend ()
0 commit comments