Pytorch installation on Jetson AGX Orin

Hi,

I’m trying to install pytorch recording this links:

When I do this all, I get this error:

yolo predict model=yolov8n.pt source='https://ultralytics.com/images/bus.jpg'
Traceback (most recent call last):
  File "/home/doruk/doruk/yolov8/yolov8/bin/yolo", line 5, in <module>
    from ultralytics.cfg import entrypoint
  File "/home/doruk/doruk/yolov8/ultralytics/__init__.py", line 5, in <module>
    from ultralytics.data.explorer.explorer import Explorer
  File "/home/doruk/doruk/yolov8/ultralytics/data/__init__.py", line 3, in <module>
    from .base import BaseDataset
  File "/home/doruk/doruk/yolov8/ultralytics/data/base.py", line 17, in <module>
    from ultralytics.data.utils import FORMATS_HELP_MSG, HELP_URL, IMG_FORMATS
  File "/home/doruk/doruk/yolov8/ultralytics/data/utils.py", line 19, in <module>
    from ultralytics.nn.autobackend import check_class_names
  File "/home/doruk/doruk/yolov8/ultralytics/nn/__init__.py", line 3, in <module>
    from .tasks import (
  File "/home/doruk/doruk/yolov8/ultralytics/nn/tasks.py", line 10, in <module>
    from ultralytics.nn.modules import (
  File "/home/doruk/doruk/yolov8/ultralytics/nn/modules/__init__.py", line 65, in <module>
    from .head import OBB, Classify, Detect, Pose, RTDETRDecoder, Segment, WorldDetect
  File "/home/doruk/doruk/yolov8/ultralytics/nn/modules/head.py", line 10, in <module>
    from ultralytics.utils.tal import TORCH_1_10, dist2bbox, dist2rbox, make_anchors
  File "/home/doruk/doruk/yolov8/ultralytics/utils/__init__.py", line 47, in <module>
    TORCHVISION_VERSION = importlib.metadata.version("torchvision")  # faster than importing torchvision
  File "/usr/lib/python3.8/importlib/metadata.py", line 530, in version
    return distribution(distribution_name).version
  File "/usr/lib/python3.8/importlib/metadata.py", line 503, in distribution
    return Distribution.from_name(distribution_name)
  File "/usr/lib/python3.8/importlib/metadata.py", line 177, in from_name
    raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: torchvision

Hi,

importlib.metadata.PackageNotFoundError: torchvision

TorchVision and PyTorch are different libraries.
Based on the error message, TorchVision is missing in your environment.
Please follow our document above to install it.

Thanks.

doruk@ubuntu:~/doruk/yolov8$ source yolov8/bin/activate
(yolov8) doruk@ubuntu:~/doruk/yolov8$ python
Python 3.8.10 (default, Nov 22 2023, 10:22:35) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torchvision
>>> import torch
>>> print(torch.__version__)
2.1.0a0+41361538.nv23.06
>>> print('CUDA available: ' + str(torch.cuda.is_available()))
CUDA available: True
>>> exit()
(yolov8) doruk@ubuntu:~/doruk/yolov8$ yolo predict model=yolov8n.pt source='https://ultralytics.com/images/bus.jpg'
Traceback (most recent call last):
  File "/home/doruk/doruk/yolov8/yolov8/bin/yolo", line 5, in <module>
    from ultralytics.cfg import entrypoint
  File "/home/doruk/doruk/yolov8/ultralytics/__init__.py", line 5, in <module>
    from ultralytics.data.explorer.explorer import Explorer
  File "/home/doruk/doruk/yolov8/ultralytics/data/__init__.py", line 3, in <module>
    from .base import BaseDataset
  File "/home/doruk/doruk/yolov8/ultralytics/data/base.py", line 17, in <module>
    from ultralytics.data.utils import FORMATS_HELP_MSG, HELP_URL, IMG_FORMATS
  File "/home/doruk/doruk/yolov8/ultralytics/data/utils.py", line 19, in <module>
    from ultralytics.nn.autobackend import check_class_names
  File "/home/doruk/doruk/yolov8/ultralytics/nn/__init__.py", line 3, in <module>
    from .tasks import (
  File "/home/doruk/doruk/yolov8/ultralytics/nn/tasks.py", line 10, in <module>
    from ultralytics.nn.modules import (
  File "/home/doruk/doruk/yolov8/ultralytics/nn/modules/__init__.py", line 65, in <module>
    from .head import OBB, Classify, Detect, Pose, RTDETRDecoder, Segment, WorldDetect
  File "/home/doruk/doruk/yolov8/ultralytics/nn/modules/head.py", line 10, in <module>
    from ultralytics.utils.tal import TORCH_1_10, dist2bbox, dist2rbox, make_anchors
  File "/home/doruk/doruk/yolov8/ultralytics/utils/__init__.py", line 47, in <module>
    TORCHVISION_VERSION = importlib.metadata.version("torchvision")  # faster than importing torchvision
  File "/usr/lib/python3.8/importlib/metadata.py", line 530, in version
    return distribution(distribution_name).version
  File "/usr/lib/python3.8/importlib/metadata.py", line 503, in distribution
    return Distribution.from_name(distribution_name)
  File "/usr/lib/python3.8/importlib/metadata.py", line 177, in from_name
    raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: torchvision
(yolov8) doruk@ubuntu:~/doruk/yolov8$ 

Hi,

Could you add --system-site-packages when creating the virtual environment?
Thanks.

In the web Installing PyTorch for Jetson Platform - NVIDIA Docs " Installing PyTorch for Jetson Platform". There is a missing “;” in the command, after ‘1.16.1’. This causes to torch not being installed. If you could change this it will be good for all the newbies in Jetson.

python3 -m pip install --upgrade pip; python3 -m pip install numpy==’1.26.1’ (missing ; ) python3 -m pip install --no-cache $TORCH_INSTALL

Hi,

Thanks for the feedback.
We will update this with our internal team.

Hi, did you solve the problem? I am having the same problem. I followed same steps in ultralytics docs.

(env3.8) jetson-orin@jetsonorin-desktop:~/Desktop/gpu$ python3
Python 3.8.10 (default, Nov 22 2023, 10:22:35)
[GCC 9.4.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import ultralytics

Traceback (most recent call last):
File “”, line 1, in
File “/home/jetson-orin/Desktop/gpu_cocacola/env3.8/lib/python3.8/site-packages/ultralytics/init.py”, line 10, in
from ultralytics.data.explorer.explorer import Explorer
File “/home/jetson-orin/Desktop/gpu_cocacola/env3.8/lib/python3.8/site-packages/ultralytics/data/init.py”, line 3, in
from .base import BaseDataset
File “/home/jetson-orin/Desktop/gpu_cocacola/env3.8/lib/python3.8/site-packages/ultralytics/data/base.py”, line 17, in
from ultralytics.data.utils import FORMATS_HELP_MSG, HELP_URL, IMG_FORMATS
File “/home/jetson-orin/Desktop/gpu_cocacola/env3.8/lib/python3.8/site-packages/ultralytics/data/utils.py”, line 19, in
from ultralytics.nn.autobackend import check_class_names
File “/home/jetson-orin/Desktop/gpu_cocacola/env3.8/lib/python3.8/site-packages/ultralytics/nn/init.py”, line 3, in
from .tasks import (
File “/home/jetson-orin/Desktop/gpu_cocacola/env3.8/lib/python3.8/site-packages/ultralytics/nn/tasks.py”, line 10, in
from ultralytics.nn.modules import (
File “/home/jetson-orin/Desktop/gpu_cocacola/env3.8/lib/python3.8/site-packages/ultralytics/nn/modules/init.py”, line 20, in
from .block import (
File “/home/jetson-orin/Desktop/gpu_cocacola/env3.8/lib/python3.8/site-packages/ultralytics/nn/modules/block.py”, line 8, in
from ultralytics.utils.torch_utils import fuse_conv_and_bn
File “/home/jetson-orin/Desktop/gpu_cocacola/env3.8/lib/python3.8/site-packages/ultralytics/utils/init.py”, line 47, in
TORCHVISION_VERSION = importlib.metadata.version(“torchvision”) # faster than importing torchvision
File “/usr/lib/python3.8/importlib/metadata.py”, line 530, in version
return distribution(distribution_name).version
File “/usr/lib/python3.8/importlib/metadata.py”, line 503, in distribution
return Distribution.from_name(distribution_name)
File “/usr/lib/python3.8/importlib/metadata.py”, line 177, in from_name
raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: torchvision

Hi,

You will need to install TorchVision to run the app.
Please find the building instructions below:

Instructions

  • Installation
    > torchvision

Thanks.

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