Torchvision setup problem

I have an issue with the installation of torchvision. I followed the installation steps from the Pytorch for Jetson website according to my Jetpack version (Jetpack 5.0.2) and had no issues with the installation of torch (PyTorch v1.13.0). However, when I try to install torchvision following the steps on the site (v0.13.0), I get the following error:

raise RuntimeError(message) from e
RuntimeError: Error compiling objects for extension

After some research, I found that this issue might be related to the PyTorch version, but I followed all the installation steps according to the version compatibility provided on the site. I couldn’t solve the issue. I would appreciate it if you could help me. Have a good day.

Hi,

Please find the below topic for the instructions to build TorchVision (under Installation):

Thanks.

Hi, thank you for your response.

I’m trying to follow the instructions you provided for the setup, but I’m getting this error.

Anyone help me pls.

Hi,

Do you mean you still meet the below error when using the instructions shared above?

RuntimeError: Error compiling objects for extension

Could you share the detailed command and output with us so we can give it a check?
Thanks.

Hello, thank you for your response. I am still encountering the errors, and the errors I am receiving are as follows. I am already grateful for any help you can provide.

/home/aura/torchvision/torchvision/csrc/ops/cuda/roi_pool_kernel.cu(141): warning: variable “device_guard” was declared but never referenced

/home/aura/torchvision/torchvision/csrc/ops/cuda/roi_pool_kernel.cu(210): warning: variable “device_guard” was declared but never referenced

/home/aura/torchvision/torchvision/csrc/ops/cuda/roi_pool_kernel.cu(85): warning: parameter “num_rois” was declared but never referenced

/home/aura/torchvision/torchvision/csrc/ops/cuda/roi_pool_kernel.cu(86): warning: parameter “spatial_scale” was declared but never referenced

ninja: build stopped: subcommand failed.
Traceback (most recent call last):
File “/home/aura/.local/lib/python3.8/site-packages/torch/utils/cpp_extension.py”, line 1896, in _run_ninja_build
subprocess.run(
File “/usr/lib/python3.8/subprocess.py”, line 516, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command ‘[‘ninja’, ‘-v’]’ returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “setup.py”, line 514, in
setup(
File “/usr/lib/python3/dist-packages/setuptools/init.py”, line 144, in setup
return distutils.core.setup(**attrs)
File “/usr/lib/python3.8/distutils/core.py”, line 148, in setup
dist.run_commands()
File “/usr/lib/python3.8/distutils/dist.py”, line 966, in run_commands
self.run_command(cmd)
File “/usr/lib/python3.8/distutils/dist.py”, line 985, in run_command
cmd_obj.run()
File “/usr/lib/python3/dist-packages/setuptools/command/install.py”, line 67, in run
self.do_egg_install()
File “/usr/lib/python3/dist-packages/setuptools/command/install.py”, line 109, in do_egg_install
self.run_command(‘bdist_egg’)
File “/usr/lib/python3.8/distutils/cmd.py”, line 313, in run_command
self.distribution.run_command(command)
File “/usr/lib/python3.8/distutils/dist.py”, line 985, in run_command
cmd_obj.run()
File “/usr/lib/python3/dist-packages/setuptools/command/bdist_egg.py”, line 172, in run
cmd = self.call_command(‘install_lib’, warn_dir=0)
File “/usr/lib/python3/dist-packages/setuptools/command/bdist_egg.py”, line 158, in call_command
self.run_command(cmdname)
File “/usr/lib/python3.8/distutils/cmd.py”, line 313, in run_command
self.distribution.run_command(command)
File “/usr/lib/python3.8/distutils/dist.py”, line 985, in run_command
cmd_obj.run()
File “/usr/lib/python3/dist-packages/setuptools/command/install_lib.py”, line 23, in run
self.build()
File “/usr/lib/python3.8/distutils/command/install_lib.py”, line 109, in build
self.run_command(‘build_ext’)
File “/usr/lib/python3.8/distutils/cmd.py”, line 313, in run_command
self.distribution.run_command(command)
File “/usr/lib/python3.8/distutils/dist.py”, line 985, in run_command
cmd_obj.run()
File “/usr/lib/python3/dist-packages/setuptools/command/build_ext.py”, line 87, in run
_build_ext.run(self)
File “/home/aura/.local/lib/python3.8/site-packages/Cython/Distutils/old_build_ext.py”, line 186, in run
_build_ext.build_ext.run(self)
File “/usr/lib/python3.8/distutils/command/build_ext.py”, line 340, in run
self.build_extensions()
File “/home/aura/.local/lib/python3.8/site-packages/torch/utils/cpp_extension.py”, line 839, in build_extensions
build_ext.build_extensions(self)
File “/home/aura/.local/lib/python3.8/site-packages/Cython/Distutils/old_build_ext.py”, line 195, in build_extensions
_build_ext.build_ext.build_extensions(self)
File “/usr/lib/python3.8/distutils/command/build_ext.py”, line 449, in build_extensions
self._build_extensions_serial()
File “/usr/lib/python3.8/distutils/command/build_ext.py”, line 474, in _build_extensions_serial
self.build_extension(ext)
File “/usr/lib/python3/dist-packages/setuptools/command/build_ext.py”, line 208, in build_extension
_build_ext.build_extension(self, ext)
File “/usr/lib/python3.8/distutils/command/build_ext.py”, line 528, in build_extension
objects = self.compiler.compile(sources,
File “/home/aura/.local/lib/python3.8/site-packages/torch/utils/cpp_extension.py”, line 654, in unix_wrap_ninja_compile
_write_ninja_file_and_compile_objects(
File “/home/aura/.local/lib/python3.8/site-packages/torch/utils/cpp_extension.py”, line 1569, in _write_ninja_file_and_compile_objects
_run_ninja_build(
File “/home/aura/.local/lib/python3.8/site-packages/torch/utils/cpp_extension.py”, line 1912, in _run_ninja_build
raise RuntimeError(message) from e
RuntimeError: Error compiling objects for extension

Screenshot from 2024-09-03 01-34-33
Screenshot from 2024-09-03 01-34-58
These are my system configurations.

Hi,

Is a newer JetPack an option for you?

It looks like there are some dependency issues between PyTorch and CUDA.
If JetPack 5.1.x works for you, it’s recommended to try PyTorch 2.1.0 and TorchVision v0.16.1.

Or you can try our container which has both PyTorch and TorchVision installed.
For JetPack 5.0.2, please use nvcr.io/nvidia/l4t-pytorch:r35.1.0-pth1.13-py3.

Thanks.

Unfortunately, I can only use version 5.0.2 as the latest version. I will follow the steps you mentioned, but I am not entirely sure what they do exactly. Are these steps helping me with the installation? Once again, thank you very much for your response.