# Torch not compiled with CUDA enabled

**URL:** <https://forums.developer.nvidia.com/t/torch-not-compiled-with-cuda-enabled/247820>\
**Category:** Jetson AGX Xavier\
**Tags:** pytorch\
**Created:** [March 28, 2023, 3:13pm UTC](https://forums.developer.nvidia.com/t/torch-not-compiled-with-cuda-enabled/247820 "2023-03-28T15:13:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eric\_Ke](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Eric\_Ke](https://forums.developer.nvidia.com/u/Eric_Ke)\
**Post date:** [March 28, 2023, 3:13pm UTC](https://forums.developer.nvidia.com/t/torch-not-compiled-with-cuda-enabled/247820/1 "2023-03-28T15:13:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dusty\_nv](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/dusty_nv/32/14043_2.png) [@dusty\_nv](https://forums.developer.nvidia.com/u/dusty_nv)\
**Post date:** [March 28, 2023, 3:56pm UTC](https://forums.developer.nvidia.com/t/torch-not-compiled-with-cuda-enabled/247820/2 "2023-03-28T15:56:35Z")

</div>

Hi @Eric_Ke, did you install the PyTorch wheel from [https://docs.nvidia.com/deeplearning/frameworks/install-pytorch-jetson-platform/index.html](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](https://catalog.ngc.nvidia.com/orgs/nvidia/containers/l4t-pytorch), which comes with PyTorch + torchvision pre-installed and is tested to have GPU working.

---

<div class="post-metadata">

**Author:** ![Eric\_Ke](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Eric\_Ke](https://forums.developer.nvidia.com/u/Eric_Ke)\
**Post date:** [March 29, 2023, 7:33am UTC](https://forums.developer.nvidia.com/t/torch-not-compiled-with-cuda-enabled/247820/5 "2023-03-29T07:33:16Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dusty\_nv](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/dusty_nv/32/14043_2.png) [@dusty\_nv](https://forums.developer.nvidia.com/u/dusty_nv)\
**Post date:** [March 29, 2023, 2:57pm UTC](https://forums.developer.nvidia.com/t/torch-not-compiled-with-cuda-enabled/247820/6 "2023-03-29T14:57:36Z")

</div>

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](https://catalog.ngc.nvidia.com/orgs/nvidia/containers/l4t-ml) container? It already has PyTorch + torchvision + pandas + scipy installed (and others)

---

<div class="post-metadata">

**Author:** ![Eric\_Ke](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Eric\_Ke](https://forums.developer.nvidia.com/u/Eric_Ke)\
**Post date:** [March 29, 2023, 4:29pm UTC](https://forums.developer.nvidia.com/t/torch-not-compiled-with-cuda-enabled/247820/7 "2023-03-29T16:29:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Eric\_Ke](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Eric\_Ke](https://forums.developer.nvidia.com/u/Eric_Ke)\
**Post date:** [March 30, 2023, 4:37am UTC](https://forums.developer.nvidia.com/t/torch-not-compiled-with-cuda-enabled/247820/8 "2023-03-30T04:37:07Z")

</div>

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

```auto
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

```auto
torch.cuda.is_available()

```

I got

```auto
False

```

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

---

<div class="post-metadata">

**Author:** ![dusty\_nv](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/dusty_nv/32/14043_2.png) [@dusty\_nv](https://forums.developer.nvidia.com/u/dusty_nv)\
**Post date:** [March 30, 2023, 3:49pm UTC](https://forums.developer.nvidia.com/t/torch-not-compiled-with-cuda-enabled/247820/9 "2023-03-30T15:49:15Z")

</div>

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

```auto
# 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.

---

<div class="post-metadata">

**Author:** ![Eric\_Ke](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Eric\_Ke](https://forums.developer.nvidia.com/u/Eric_Ke)\
**Post date:** [March 31, 2023, 9:03am UTC](https://forums.developer.nvidia.com/t/torch-not-compiled-with-cuda-enabled/247820/10 "2023-03-31T09:03:47Z")

</div>

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().

```auto
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

```

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/system/32/68080_2.png) [@system](https://forums.developer.nvidia.com/u/system)\
**Post date:** [April 25, 2023, 7:58am UTC](https://forums.developer.nvidia.com/t/torch-not-compiled-with-cuda-enabled/247820/12 "2023-04-25T07:58:44Z")

</div>

Closed on April 25, 2023, 7:58am UTC

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