Torch not compiled with CUDA enabled

I try to execute yolov7 train on agx xavier module 32gb but I encounter a problem:
raise AssertionError(“Torch not compiled with CUDA enabled”)
AssertionError: Torch not compiled with CUDA enabled

When installing jetson’s pytorch, I found that the torch version of jetpack5.1 is 2.0, and the information on the official website of pytorch shows that it only supports cuda11.7 or 11.8, so I upgraded agx’s cuda11.4 to 11.8, but this problem still hasn’t been solved.

Hi @Eric_Ke, did you install the PyTorch wheel from https://docs.nvidia.com/deeplearning/frameworks/install-pytorch-jetson-platform/index.html ? Those are built with CUDA enabled. You shouldn’t need to upgrade CUDA in order to use them - they were built against the version of CUDA that comes with JetPack.

You could also use the l4t-pytorch container, which comes with PyTorch + torchvision pre-installed and is tested to have GPU working.

Yes, I installed it according to the URL. Just now I changed the CUDA version back to 11.4 and still got the same error. Then I tried to re-run the compilation of pytorch. I entered it line by line during the installation. When I entered to
python3 -m pip install aiohttp numpy=='1.19.4' scipy=='1.5.3',

An error occurred: ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behavior is the source of the following dependency conflicts. pandas 1.5.3 requires numpy>=1.20.3; python_version < "3.10", but you have numpy 1.19.4 which is incompatible. matplotlib 3.7.1 requires numpy>=1.20, but you have numpy 1.19.4 which is incompatible.

And when I typed python3 -m pip install --upgrade protobuf , I encountered an error:
ERROR:pip's dependency resolver does not currently take into account all the packages that are installed. This behavior is the source of the following dependency conflicts.onnx 1.13.1 requires protobuf<4,>=3.20.2, but you have protobuf 4.22.1 which is incompatible.

How can I deal with these errors?

Given the packages that you’ve tried to install and the different CUDA versions you’ve had, it’s difficult for me to speak to what your environment may currently be like. Can you try using the l4t-ml container? It already has PyTorch + torchvision + pandas + scipy installed (and others)

I can refill AGX Xavier to use the latest jetpack5.1.1 and then install pytorch, and then test whether there is any problem, thank you for your continuous reply.

I use a new Jetpack5.1.1 to install pytorch only a little error , it’s at I run python3 -m pip install aiohttp numpy=='1.19.4' scipy=='1.5.3'

the error is ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. onnx-graphsurgeon 0.3.12 requires onnx, which is not installed.

I use python3 -m pip install onnx to fix it

and then I run python3 -m pip install --upgrade protobuf , I get a error is ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. onnx 1.13.1 requires protobuf<4,>=3.20.2, but you have protobuf 4.22.1 which is incompatible.

okay , i try to use python3 -m pip install --upgrade onnx fix it ,but I found Successfully uninstalled protobuf-4.22.1 Successfully installed protobuf-3.20.3
protobuf version is go back to 3.20.3

next I run python3 -m pip install --no-cache $TORCH_INSTALL it’s great , I don’t get any error.

next i try to test pytorch is installed.
import torch
torch.cuda.current_device()
I got

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/isasp/.local/lib/python3.8/site-packages/torch/cuda/__init__.py", line 674, in current_device
    _lazy_init() File "/home/isasp/.local/lib/python3.8/site-packages/torch/cuda/__init__.py", line 239, in _lazy_init raise AssertionError("Torch not compiled with CUDA enabled") AssertionError: Torch not compiled with CUDA enabled

and I keep run

torch.cuda.is_available()

I got

False

so …could you tell me how to fix this? Let pytorch compiled with CUDA enabled. Thank you so much.

@Eric_Ke please try this sequence instead (start again with a clean environment if you need to):

# remove previous
pip3 uninstall torch
pip3 uninstall numpy

# https://forums.developer.nvidia.com/t/pytorch-for-jetson/72048
sudo apt-get install python3-pip libopenblas-base libopenmpi-dev libomp-dev
pip3 install Cython
pip3 install numpy
pip3 install https://developer.download.nvidia.com/compute/redist/jp/v51/pytorch/torch-2.0.0a0+8aa34602.nv23.03-cp38-cp38-linux_aarch64.whl

If you continue having issues, I recommend you use the l4t-pytorch or l4t-ml containers. They already have PyTorch + torchvision pre-installed (with GPU support) and will keep from all these package conflicts getting installed into your main environment so you aren’t having to re-flash.

Thank you!!! I used new a clean environment (jetpack5.1.1) and your step . Now my Pytorch can return cuda.current_device() and cuda.is_available().

Python 3.8.10 (default, Mar 13 2023, 10:26:41) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.cuda.current_device()
0
>>> torch.cuda.is_available()
True

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