How to completely execute python code using CUDA

I have been trying to run a facial detection program to be executed on GPU. Unfortunately, the program seems to be executing on the CPU and not on the GPU.

Thanks In advance.


Could you share more information about your use case?

Which framework do you use? PyTorch or TensorFlow?
How do you install the package? Do you install the package with CUDA support?

Have you converted the model to TensorRT?


Yes, I have installed CUDA support and trying to go with PyTorch.


Is your PyTorch built with CUDA enabled?

You can try our prebuilt which is compiled with CUDA support.

Please notice that the command in the doc is for JetPack 5 users.
You will need to change it to the JetPack you used manually.


It throws the error saying :

AssertionError: Torch not compiled with CUDA enabled

And this is the whole error:

Using cache found in /home/jetson/.cache/torch/hub/pytorch_vision_main
/home/jetson/.cache/torch/hub/pytorch_vision_main/torchvision/io/ UserWarning: Failed to load image Python extension: ''If you don't plan on using image functionality from ``, you can ignore this warning. Otherwise, there might be something wrong with your environment. Did you have `libjpeg` or `libpng` installed before building `torchvision` from source?
/home/jetson/.cache/torch/hub/pytorch_vision_main/torchvision/models/detection/ UserWarning: Failed to initialize NumPy: module compiled against API version 0xf but this version of numpy is 0xe (Triggered internally at /root/pytorch/torch/csrc/utils/tensor_numpy.cpp:77.)
  device: torch.device = torch.device("cpu"),
/home/jetson/.cache/torch/hub/pytorch_vision_main/torchvision/models/ UserWarning: The parameter 'pretrained' is deprecated since 0.13 and may be removed in the future, please use 'weights' instead.
/home/jetson/.cache/torch/hub/pytorch_vision_main/torchvision/models/ UserWarning: Arguments other than a weight enum or `None` for 'weights' are deprecated since 0.13 and may be removed in the future. The current behavior is equivalent to passing `weights=ResNet18_Weights.IMAGENET1K_V1`. You can also use `weights=ResNet18_Weights.DEFAULT` to get the most up-to-date weights.
Traceback (most recent call last):
  File "", line 487, in <module>
    model ='cuda')
  File "/home/jetson/.local/lib/python3.8/site-packages/torch/nn/modules/", line 989, in to
    return self._apply(convert)
  File "/home/jetson/.local/lib/python3.8/site-packages/torch/nn/modules/", line 641, in _apply
  File "/home/jetson/.local/lib/python3.8/site-packages/torch/nn/modules/", line 664, in _apply
    param_applied = fn(param)
  File "/home/jetson/.local/lib/python3.8/site-packages/torch/nn/modules/", line 987, in convert
    return, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking)
  File "/home/jetson/.local/lib/python3.8/site-packages/torch/cuda/", line 221, in _lazy_init
    raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabled

I will try the method you mentioned as well.



Based on the error, the package doesn’t build with CUDA.
Please let us know if our prebuilt help with your issue.


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.