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.

Hi,

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?

Thanks.

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

Hi,

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.

Thanks.

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/image.py:13: UserWarning: Failed to load image Python extension: ''If you don't plan on using image functionality from `torchvision.io`, 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?
  warn(
/home/jetson/.cache/torch/hub/pytorch_vision_main/torchvision/models/detection/anchor_utils.py:63: 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/_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and may be removed in the future, please use 'weights' instead.
  warnings.warn(
/home/jetson/.cache/torch/hub/pytorch_vision_main/torchvision/models/_utils.py:223: 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.
  warnings.warn(msg)
Traceback (most recent call last):
  File "test.py", line 487, in <module>
    model = model.to('cuda')
  File "/home/jetson/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 989, in to
    return self._apply(convert)
  File "/home/jetson/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 641, in _apply
    module._apply(fn)
  File "/home/jetson/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 664, in _apply
    param_applied = fn(param)
  File "/home/jetson/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 987, in convert
    return t.to(device, 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/__init__.py", 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.

Thanks

Hi,

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

Thanks.

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