Torch fails to find cpp_extension

I am building a docker image to run machine learning models inside, specifically grounding DINO, which uses some C++ modules to optimise the attention module. However, when I run the docker image, the Grounding DINO install always falls back to CPU mode having failed to build this C++ code:

try:
    from groundingdino import _C
except:
    warnings.warn("Failed to load custom C++ ops. Running on CPU mode Only!")

I have done some digging in the container command line, and noticed that Torch and specifically the cpp_extension function from utils are not set up correctly, despite the versions being correct AFAICT:

>>> torch.__version__
'2.3.0+cu121'
>>> torch.utils.get_cpp_extension()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'torch.utils' has no attribute 'get_cpp_extension'

I have no clue why torch.utils doesnt include this function, as the version looks correct?

The linked docs do not show a get_cpp_extension() call or am I missing it?
Are you looking for torch.utils.cpp_extension.CppExtension?