Working with pytorch>2.5

Hi all

For a project i’m trying to run the “segmentation_models_pytorch” library, which requires pytorch>2.5

I couldn’t find it on PyTorch for Jetson - Jetson & Embedded Systems / Announcements - NVIDIA Developer Forums

So then i tried doing it via jetson-containers, as according to Dusty from nvidia it should work:

dusty-nv/jetson-containers: Machine Learning Containers for NVIDIA Jetson and JetPack-L4T

Container for Pytorch >= 2.5.0 - Jetson & Embedded Systems / Jetson AGX Orin - NVIDIA Developer Forums

jetson-containers build --name=my_pytorch_container pytorch however errors out.

The full log:

DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
            BuildKit is currently disabled; enable it by removing the DOCKER_BUILDKIT=0
            environment-variable.

Sending build context to Docker daemon  19.97kB

Step 1/5 : ARG BASE_IMAGE
Step 2/5 : FROM ${BASE_IMAGE}
 ---> 981912c48e9a
Step 3/5 : ENV DEBIAN_FRONTEND=noninteractive     LANGUAGE=en_US:en     LANG=en_US.UTF-8     LC_ALL=en_US.UTF-8
 ---> Using cache
 ---> 8e698c1ab824
Step 4/5 : RUN set -ex     && apt-get update     && apt-get install -y --no-install-recommends         locales         locales-all         tzdata     && locale-gen en_US $LANG     && update-locale LC_ALL=$LC_ALL LANG=$LANG     && locale         && apt-get install -y --no-install-recommends         build-essential         software-properties-common         apt-transport-https         ca-certificates         lsb-release         pkg-config         gnupg         git         git-lfs         gdb         wget         wget2         curl         nano         zip         unzip         time         sshpass         ssh-client     && apt-get clean     && rm -rf /var/lib/apt/lists/*         && gcc --version     && g++ --version
 ---> Using cache
 ---> fb0aa93d1c72
Step 5/5 : COPY tarpack /usr/local/bin/
 ---> Using cache
 ---> 857cbaf28680
Successfully built 857cbaf28680
Successfully tagged my_pytorch_container:r36.4.3-cu124-build-essential
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
            BuildKit is currently disabled; enable it by removing the DOCKER_BUILDKIT=0
            environment-variable.

Sending build context to Docker daemon  40.45kB

Step 1/4 : ARG BASE_IMAGE
Step 2/4 : FROM ${BASE_IMAGE}
 ---> 857cbaf28680
Step 3/4 : ARG PIP_INDEX_REPO     PIP_UPLOAD_REPO     PIP_UPLOAD_USER     PIP_UPLOAD_PASS     PIP_TRUSTED_HOSTS     TAR_INDEX_URL     SCP_UPLOAD_URL     SCP_UPLOAD_USER     SCP_UPLOAD_PASS
 ---> Using cache
 ---> 4c11788fc1bc
Step 4/4 : ENV TAR_INDEX_URL=${TAR_INDEX_URL}     PIP_INDEX_URL=${PIP_INDEX_REPO}     PIP_TRUSTED_HOST=${PIP_TRUSTED_HOSTS}     TWINE_REPOSITORY_URL=${PIP_UPLOAD_REPO}     TWINE_USERNAME=${PIP_UPLOAD_USER}     TWINE_PASSWORD=${PIP_UPLOAD_PASS}     SCP_UPLOAD_URL=${SCP_UPLOAD_URL}     SCP_UPLOAD_USER=${SCP_UPLOAD_USER}     SCP_UPLOAD_PASS=${SCP_UPLOAD_PASS}
 ---> Using cache
 ---> a536bc73e566
Successfully built a536bc73e566
Successfully tagged my_pytorch_container:r36.4.3-cu124-pip_cache_cu124
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
            BuildKit is currently disabled; enable it by removing the DOCKER_BUILDKIT=0
            environment-variable.

Sending build context to Docker daemon  40.45kB

Step 1/9 : ARG BASE_IMAGE
Step 2/9 : FROM ${BASE_IMAGE}
 ---> a536bc73e566
Step 3/9 : ARG CUDA_URL     CUDA_DEB     CUDA_PACKAGES     CUDA_ARCH_LIST     DISTRO="ubuntu2004"
 ---> Using cache
 ---> b96c8ba879fb
Step 4/9 : COPY install.sh /tmp/install_cuda.sh
 ---> Using cache
 ---> 09ab437cfdcb
Step 5/9 : RUN /tmp/install_cuda.sh
 ---> Using cache
 ---> da3f76ef4b6f
Step 6/9 : ENV CUDA_HOME="/usr/local/cuda"
 ---> Using cache
 ---> 8bad0cecda61
Step 7/9 : ENV NVCC_PATH="$CUDA_HOME/bin/nvcc"
 ---> Using cache
 ---> b374566a2c41
Step 8/9 : ENV NVIDIA_VISIBLE_DEVICES=all     NVIDIA_DRIVER_CAPABILITIES=all     CUDAARCHS=${CUDA_ARCH_LIST}     CUDA_ARCHITECTURES=${CUDA_ARCH_LIST}     CUDA_HOME="/usr/local/cuda"     CUDNN_LIB_PATH="/usr/lib/aarch64-linux-gnu"     CUDNN_LIB_INCLUDE_PATH="/usr/include"     CMAKE_CUDA_COMPILER=${NVCC_PATH}     CUDA_NVCC_EXECUTABLE=${NVCC_PATH}     CUDACXX=${NVCC_PATH}     TORCH_NVCC_FLAGS="-Xfatbin -compress-all"     CUDA_BIN_PATH="${CUDA_HOME}/bin"     CUDA_TOOLKIT_ROOT_DIR="${CUDA_HOME}"     PATH="$CUDA_HOME/bin:${PATH}"     LD_LIBRARY_PATH="${CUDA_HOME}/compat:${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}"     DEBIAN_FRONTEND=noninteractive
 ---> Using cache
 ---> 47ed8950e010
Step 9/9 : WORKDIR /
 ---> Using cache
 ---> 21d2b7d0204d
Successfully built 21d2b7d0204d
Successfully tagged my_pytorch_container:r36.4.3-cu124-cuda_12.4
{
   "cuda" : {
      "name" : "CUDA SDK",
      "version" : "12.4.1"
   },
   "cuda_cccl" : {
      "name" : "CUDA C++ Core Compute Libraries",
      "version" : "12.4.127"
   },
   "cuda_compat" : {
      "name" : "CUDA Specific Libraries",
      "version" : "12.4.35753180"
   },
   "cuda_cudart" : {
      "name" : "CUDA Runtime (cudart)",
      "version" : "12.4.127"
   },
   "cuda_cuobjdump" : {
      "name" : "cuobjdump",
      "version" : "12.4.127"
   },
   "cuda_cupti" : {
      "name" : "CUPTI",
      "version" : "12.4.127"
   },
   "cuda_cuxxfilt" : {
      "name" : "CUDA cu++ filt",
      "version" : "12.4.127"
   },
   "cuda_gdb" : {
      "name" : "CUDA GDB",
      "version" : "12.4.127"
   },
   "cuda_nvcc" : {
      "name" : "CUDA NVCC",
      "version" : "12.4.131"
   },
   "cuda_nvdisasm" : {
      "name" : "CUDA nvdisasm",
      "version" : "12.4.127"
   },
   "cuda_nvml_dev" : {
      "name" : "CUDA NVML Headers",
      "version" : "12.4.127"
   },
   "cuda_nvprune" : {
      "name" : "CUDA nvprune",
      "version" : "12.4.127"
   },
   "cuda_nvrtc" : {
      "name" : "CUDA NVRTC",
      "version" : "12.4.127"
   },
   "cuda_nvtx" : {
      "name" : "CUDA NVTX",
      "version" : "12.4.127"
   },
   "cuda_sanitizer_api" : {
      "name" : "CUDA Compute Sanitizer API",
      "version" : "12.4.127"
   },
   "libcublas" : {
      "name" : "CUDA cuBLAS",
      "version" : "12.4.5.8"
   },
   "libcudla" : {
      "name" : "CUDA cuDLA",
      "version" : "12.4.127"
   },
   "libcufft" : {
      "name" : "CUDA cuFFT",
      "version" : "11.2.1.3"
   },
   "libcufile" : {
      "name" : "GPUDirect Storage (cufile)",
      "version" : "1.9.1.3"
   },
   "libcurand" : {
      "name" : "CUDA cuRAND",
      "version" : "10.3.5.147"
   },
   "libcusolver" : {
      "name" : "CUDA cuSOLVER",
      "version" : "11.6.1.9"
   },
   "libcusparse" : {
      "name" : "CUDA cuSPARSE",
      "version" : "12.3.1.170"
   },
   "libnpp" : {
      "name" : "CUDA NPP",
      "version" : "12.2.5.30"
   },
   "libnvfatbin" : {
      "name" : "Fatbin interaction library",
      "version" : "12.4.127"
   },
   "libnvjitlink" : {
      "name" : "JIT Linker Library",
      "version" : "12.4.127"
   },
   "libnvjpeg" : {
      "name" : "CUDA nvJPEG",
      "version" : "12.3.1.117"
   },
   "nsight_compute" : {
      "name" : "Nsight Compute",
      "version" : "2024.1.1.4"
   },
   "nvidia_fs" : {
      "name" : "NVIDIA file-system",
      "version" : "2.19.7"
   }
}
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
            BuildKit is currently disabled; enable it by removing the DOCKER_BUILDKIT=0
            environment-variable.

Sending build context to Docker daemon  22.53kB

Step 1/7 : ARG BASE_IMAGE
Step 2/7 : FROM ${BASE_IMAGE}
 ---> 21d2b7d0204d
Step 3/7 : ARG CUDNN_URL
 ---> Using cache
 ---> 3d3095a73b91
Step 4/7 : ARG CUDNN_DEB
 ---> Using cache
 ---> 81fd77b0d4d8
Step 5/7 : ARG CUDNN_PACKAGES
 ---> Using cache
 ---> af5748cefa94
Step 6/7 : RUN echo "Downloading ${CUDNN_DEB}" &&     mkdir /tmp/cudnn && cd /tmp/cudnn &&     wget --quiet --show-progress --progress=bar:force:noscroll ${CUDNN_URL} &&     dpkg -i *.deb &&     cp /var/cudnn-local-tegra-repo-*/cudnn-local-tegra-*-keyring.gpg /usr/share/keyrings/ &&     apt-get update &&     apt-cache search cudnn &&     apt-get install -y --no-install-recommends ${CUDNN_PACKAGES} &&     rm -rf /var/lib/apt/lists/* &&     apt-get clean &&     dpkg --list | grep cudnn &&     dpkg -P ${CUDNN_DEB} &&     rm -rf /tmp/cudnn
 ---> Using cache
 ---> 281553bc8601
Step 7/7 : RUN cd /usr/src/cudnn_samples_v*/conv_sample/ &&     make -j$(nproc)
 ---> Using cache
 ---> 572a8ed4255f
Successfully built 572a8ed4255f
Successfully tagged my_pytorch_container:r36.4.3-cu124-cudnn
#define CUDNN_MAJOR 9
#define CUDNN_MINOR 0
#define CUDNN_VERSION (CUDNN_MAJOR * 10000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL)
#define CUDNN_MAX_SM_MAJOR_NUMBER 9
#define CUDNN_MAX_SM_MINOR_NUMBER 0
#define CUDNN_MAX_DEVICE_VERSION (CUDNN_MAX_SM_MAJOR_NUMBER * 100 + CUDNN_MAX_SM_MINOR_NUMBER * 10)
Executing: conv_sample
double free or corruption (out)
test.sh: line 14:    23 Aborted                 (core dumped) ./conv_sample
Namespace(packages=['pytorch'], name='my_pytorch_container', base='', multiple=False, build_flags='', build_args='', package_dirs=[''], list_packages=False, show_packages=False, skip_packages=[''], skip_errors=False, skip_tests=[''], test_only=[''], simulate=False, push='', logs='', verbose=False, no_github_api=False)
-- L4T_VERSION=36.4.3
-- JETPACK_VERSION=5.1
-- CUDA_VERSION=12.4
-- PYTHON_VERSION=3.10
-- LSB_RELEASE=22.04 (jammy)
-- Building containers  ['build-essential', 'pip_cache:cu124', 'cuda:12.4', 'cudnn', 'python', 'numpy', 'cmake', 'onnx', 'pytorch']
-- Building container my_pytorch_container:r36.4.3-cu124-build-essential

sudo DOCKER_BUILDKIT=0 docker build --network=host --tag my_pytorch_container:r36.4.3-cu124-build-essential \
--file /home/bdck/PROJECTS/semantic_segmentation/jetson-containers/packages/build/build-essential/Dockerfile \
--build-arg BASE_IMAGE=ubuntu:22.04 \
/home/bdck/PROJECTS/semantic_segmentation/jetson-containers/packages/build/build-essential \
2>&1 | tee /home/bdck/PROJECTS/semantic_segmentation/jetson-containers/logs/20250117_135724/build/my_pytorch_container_r36.4.3-cu124-build-essential.txt; exit ${PIPESTATUS[0]}

-- Building container my_pytorch_container:r36.4.3-cu124-pip_cache_cu124

sudo DOCKER_BUILDKIT=0 docker build --network=host --tag my_pytorch_container:r36.4.3-cu124-pip_cache_cu124 \
--file /home/bdck/PROJECTS/semantic_segmentation/jetson-containers/packages/cuda/cuda/Dockerfile.pip \
--build-arg BASE_IMAGE=my_pytorch_container:r36.4.3-cu124-build-essential \
--build-arg TAR_INDEX_URL="https://apt.jetson-ai-lab.dev:8000/jp5/cu124" \
--build-arg PIP_INDEX_REPO="https://pypi.jetson-ai-lab.dev/jp5/cu124" \
--build-arg PIP_UPLOAD_REPO="http://localhost/jp5/cu124" \
--build-arg PIP_UPLOAD_USER="jp5" \
--build-arg PIP_UPLOAD_PASS="none" \
--build-arg SCP_UPLOAD_URL="localhost:/dist/jp5/cu124" \
--build-arg SCP_UPLOAD_USER="None" \
--build-arg SCP_UPLOAD_PASS="None" \
/home/bdck/PROJECTS/semantic_segmentation/jetson-containers/packages/cuda/cuda \
2>&1 | tee /home/bdck/PROJECTS/semantic_segmentation/jetson-containers/logs/20250117_135724/build/my_pytorch_container_r36.4.3-cu124-pip_cache_cu124.txt; exit ${PIPESTATUS[0]}

-- Building container my_pytorch_container:r36.4.3-cu124-cuda_12.4

sudo DOCKER_BUILDKIT=0 docker build --network=host --tag my_pytorch_container:r36.4.3-cu124-cuda_12.4 \
--file /home/bdck/PROJECTS/semantic_segmentation/jetson-containers/packages/cuda/cuda/Dockerfile \
--build-arg BASE_IMAGE=my_pytorch_container:r36.4.3-cu124-pip_cache_cu124 \
--build-arg CUDA_URL="https://developer.download.nvidia.com/compute/cuda/12.4.1/local_installers/cuda-tegra-repo-ubuntu2204-12-4-local_12.4.1-1_arm64.deb" \
--build-arg CUDA_DEB="cuda-tegra-repo-ubuntu2204-12-4-local" \
--build-arg CUDA_PACKAGES="cuda-toolkit*" \
--build-arg CUDA_ARCH_LIST="87" \
--build-arg DISTRO="ubuntu2204" \
/home/bdck/PROJECTS/semantic_segmentation/jetson-containers/packages/cuda/cuda \
2>&1 | tee /home/bdck/PROJECTS/semantic_segmentation/jetson-containers/logs/20250117_135724/build/my_pytorch_container_r36.4.3-cu124-cuda_12.4.txt; exit ${PIPESTATUS[0]}

-- Testing container my_pytorch_container:r36.4.3-cu124-cuda_12.4 (cuda:12.4/test.sh)

sudo docker run -t --rm --runtime=nvidia --network=host \
--volume /home/bdck/PROJECTS/semantic_segmentation/jetson-containers/packages/cuda/cuda:/test \
--volume /home/bdck/PROJECTS/semantic_segmentation/jetson-containers/data:/data \
--workdir /test \
my_pytorch_container:r36.4.3-cu124-cuda_12.4 \
/bin/bash -c '/bin/bash test.sh' \
2>&1 | tee /home/bdck/PROJECTS/semantic_segmentation/jetson-containers/logs/20250117_135724/test/my_pytorch_container_r36.4.3-cu124-cuda_12.4_test.sh.txt; exit ${PIPESTATUS[0]}

-- Building container my_pytorch_container:r36.4.3-cu124-cudnn

sudo DOCKER_BUILDKIT=0 docker build --network=host --tag my_pytorch_container:r36.4.3-cu124-cudnn \
--file /home/bdck/PROJECTS/semantic_segmentation/jetson-containers/packages/cuda/cudnn/Dockerfile \
--build-arg BASE_IMAGE=my_pytorch_container:r36.4.3-cu124-cuda_12.4 \
--build-arg CUDNN_URL="https://developer.download.nvidia.com/compute/cudnn/9.0.0/local_installers/cudnn-local-tegra-repo-ubuntu2204-9.0.0_1.0-1_arm64.deb" \
--build-arg CUDNN_DEB="cudnn-local-tegra-repo-ubuntu2204-9.0.0" \
--build-arg CUDNN_PACKAGES="libcudnn*-dev libcudnn*-samples" \
/home/bdck/PROJECTS/semantic_segmentation/jetson-containers/packages/cuda/cudnn \
2>&1 | tee /home/bdck/PROJECTS/semantic_segmentation/jetson-containers/logs/20250117_135724/build/my_pytorch_container_r36.4.3-cu124-cudnn.txt; exit ${PIPESTATUS[0]}

-- Testing container my_pytorch_container:r36.4.3-cu124-cudnn (cudnn:9.0/test.sh)

sudo docker run -t --rm --runtime=nvidia --network=host \
--volume /home/bdck/PROJECTS/semantic_segmentation/jetson-containers/packages/cuda/cudnn:/test \
--volume /home/bdck/PROJECTS/semantic_segmentation/jetson-containers/data:/data \
--workdir /test \
my_pytorch_container:r36.4.3-cu124-cudnn \
/bin/bash -c '/bin/bash test.sh' \
2>&1 | tee /home/bdck/PROJECTS/semantic_segmentation/jetson-containers/logs/20250117_135724/test/my_pytorch_container_r36.4.3-cu124-cudnn_test.sh.txt; exit ${PIPESTATUS[0]}

more error:

Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/bdck/PROJECTS/semantic_segmentation/jetson-containers/jetson_containers/build.py", line 112, in <module>
    build_container(args.name, args.packages, args.base, args.build_flags, args.build_args, args.simulate, args.skip_tests, args.test_only, args.push, args.no_github_api, args.skip_packages)
  File "/home/bdck/PROJECTS/semantic_segmentation/jetson-containers/jetson_containers/container.py", line 154, in build_container
    test_container(container_name, pkg, simulate)
  File "/home/bdck/PROJECTS/semantic_segmentation/jetson-containers/jetson_containers/container.py", line 327, in test_container
    status = subprocess.run(cmd.replace(_NEWLINE_, ' '), executable='/bin/bash', shell=True, check=True)
  File "/usr/lib/python3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'sudo docker run -t --rm --runtime=nvidia --network=host --volume /home/bdck/PROJECTS/semantic_segmentation/jetson-containers/packages/cuda/cudnn:/test --volume /home/bdck/PROJECTS/semantic_segmentation/jetson-containers/data:/data --workdir /test my_pytorch_container:r36.4.3-cu124-cudnn /bin/bash -c '/bin/bash test.sh' 2>&1 | tee /home/bdck/PROJECTS/semantic_segmentation/jetson-containers/logs/20250117_135724/test/my_pytorch_container_r36.4.3-cu124-cudnn_test.sh.txt; exit ${PIPESTATUS[0]}' returned non-zero exit status 134.


You will have to build it from source. Look at the chart on pytorch site and you must have the exact version of cuda installed before you start. I did a native build and it runs fine, no docker.

Hi, I’ve still been struggling with this over the whole weekend.

  • I haven’t found a pytorch 2.5.1 or higher to build natively on the jetson.
  • torch 2.5.0 doesn’t seem enough to use the “segmentation models pytorch” library

Would you be so kind to explain how you did it more in detail?
Thx

Hi,

Below commands are for pytorch 2.6, you could try install it in virtualenv

1. Set up the Virtual Environment

$ sudo apt-get install virtualenv
$ python3 -m virtualenv -p python3 <chosen_venv_name>
$ source <chosen_venv_name>/bin/activate

2.  Install pytorch and torchvision
$ wget https://pypi.jetson-ai-lab.dev/jp6/cu126/+f/a86/1895294d90440/torch-2.6.0rc1-cp310-cp310-linux_aarch64.whl#sha256=a861895294d90440f2cdbd863d3fd5407fcc346f819665f3a63d90dfcf41a5b0
$ pip install torch-2.6.0rc1-cp310-cp310-linux_aarch64.whl 
$ wget https://pypi.jetson-ai-lab.dev/jp6/cu126/+f/5f9/67f920de3953f/torchvision-0.20.0-cp310-cp310-linux_aarch64.whl#sha256=5f967f920de3953f2a39d95154b1feffd5ccc06b4589e51540dc070021a9adb9
$ pip install torchvision-0.20.0-cp310-cp310-linux_aarch64.whl

Thanks

Hi

Thanks for the good info and quick reply. My current pip freeze is now this:

albucore==0.0.23
albumentations==2.0.0
annotated-types==0.7.0
certifi==2024.12.14
charset-normalizer==3.4.1
contourpy==1.3.1
cycler==0.12.1
filelock==3.16.1
fonttools==4.55.3
fsspec==2024.12.0
huggingface-hub==0.27.1
idna==3.10
Jinja2==3.1.5
kiwisolver==1.4.8
loguru==0.7.3
MarkupSafe==3.0.2
matplotlib==3.10.0
mpmath==1.3.0
munch==4.0.0
networkx==3.4.2
numpy==2.2.2
opencv-python-headless==4.11.0.86
packaging==24.2
pillow==11.1.0
pretrainedmodels==0.7.4
pydantic==2.10.5
pydantic_core==2.27.2
pyparsing==3.2.1
python-dateutil==2.9.0.post0
PyYAML==6.0.2
requests==2.32.3
safetensors==0.5.2
scipy==1.15.1
segmentation_models_pytorch @ git+https://github.com/qubvel/segmentation_models.pytorch@709a7494fd1ee86fb0b4b2635d30e95a4d2e1ec8
simsimd==6.2.1
six==1.17.0
stringzilla==3.11.3
sympy==1.13.1
timm==1.0.14
torch @ file:///home/bdck/PROJECTS/semantic_segmentation/torch-2.6.0rc1-cp310-cp310-linux_aarch64.whl
torchvision @ file:///home/bdck/PROJECTS/semantic_segmentation/torchvision-0.20.0-cp310-cp310-linux_aarch64.whl
tqdm==4.67.1
typing_extensions==4.12.2
urllib3==2.3.0

However for some reason i get the following error? I cant remember ever using numpy 1.x? (or is the error in torchvision)


A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.2.2 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

Traceback (most recent call last):  File "/home/bdck/PROJECTS/semantic_segmentation/RBPI/model_inferenceRBPI.py", line 2, in <module>
    import torch
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/torch/__init__.py", line 2196, in <module>
    from torch import quantization as quantization  # usort: skip
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/torch/quantization/__init__.py", line 2, in <module>
    from .fake_quantize import *  # noqa: F403
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/torch/quantization/fake_quantize.py", line 10, in <module>
    from torch.ao.quantization.fake_quantize import (
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/torch/ao/quantization/__init__.py", line 12, in <module>
    from .pt2e._numeric_debugger import (  # noqa: F401
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/torch/ao/quantization/pt2e/_numeric_debugger.py", line 9, in <module>
    from torch.export import ExportedProgram
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/torch/export/__init__.py", line 68, in <module>
    from .decomp_utils import CustomDecompTable
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/torch/export/decomp_utils.py", line 5, in <module>
    from torch._export.utils import (
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/torch/_export/__init__.py", line 48, in <module>
    from .wrappers import _wrap_submodules
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/torch/_export/wrappers.py", line 7, in <module>
    from torch._higher_order_ops.strict_mode import strict_mode
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/torch/_higher_order_ops/__init__.py", line 1, in <module>
    from torch._higher_order_ops.cond import cond
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/torch/_higher_order_ops/cond.py", line 9, in <module>
    import torch._subclasses.functional_tensor
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/torch/_subclasses/functional_tensor.py", line 45, in <module>
    class FunctionalTensor(torch.Tensor):
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/torch/_subclasses/functional_tensor.py", line 275, in FunctionalTensor
    cpu = _conversion_method_template(device=torch.device("cpu"))
/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/torch/_subclasses/functional_tensor.py:275: UserWarning: Failed to initialize NumPy: 
A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.2.2 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

 (Triggered internally at /opt/pytorch/torch/csrc/utils/tensor_numpy.cpp:81.)
  cpu = _conversion_method_template(device=torch.device("cpu"))
Traceback (most recent call last):
  File "/home/bdck/PROJECTS/semantic_segmentation/RBPI/model_inferenceRBPI.py", line 9, in <module>
    import segmentation_models_pytorch as smp
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/segmentation_models_pytorch/__init__.py", line 4, in <module>
    from . import encoders
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/segmentation_models_pytorch/encoders/__init__.py", line 2, in <module>
    import timm
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/timm/__init__.py", line 2, in <module>
    from .layers import is_scriptable, is_exportable, set_scriptable, set_exportable
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/timm/layers/__init__.py", line 8, in <module>
    from .classifier import create_classifier, ClassifierHead, NormMlpClassifierHead, ClNormMlpClassifierHead
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/timm/layers/classifier.py", line 15, in <module>
    from .create_norm import get_norm_layer
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/timm/layers/create_norm.py", line 14, in <module>
    from torchvision.ops.misc import FrozenBatchNorm2d
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/torchvision/__init__.py", line 10, in <module>
    from torchvision import _meta_registrations, datasets, io, models, ops, transforms, utils  # usort:skip
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/torchvision/_meta_registrations.py", line 164, in <module>
    def meta_nms(dets, scores, iou_threshold):
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/torch/library.py", line 828, in register
    use_lib._register_fake(op_name, func, _stacklevel=stacklevel + 1)
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/torch/library.py", line 198, in _register_fake
    handle = entry.fake_impl.register(func_to_register, source)
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/torch/_library/fake_impl.py", line 31, in register
    if torch._C._dispatch_has_kernel_for_dispatch_key(self.qualname, "Meta"):
RuntimeError: operator torchvision::nms does not exist

Thanks

Hi,

it might be depend problem

do following command.

pip uninstall numpy
pip install "numpy<2"

Thanks

Ah, that indeed fixes the first part of my error. Now i do still have the following (torchvision?) error:

Traceback (most recent call last):
  File "/home/bdck/PROJECTS/semantic_segmentation/RBPI/model_inferenceRBPI.py", line 9, in <module>
    import segmentation_models_pytorch as smp
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/segmentation_models_pytorch/__init__.py", line 4, in <module>
    from . import encoders
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/segmentation_models_pytorch/encoders/__init__.py", line 2, in <module>
    import timm
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/timm/__init__.py", line 2, in <module>
    from .layers import is_scriptable, is_exportable, set_scriptable, set_exportable
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/timm/layers/__init__.py", line 8, in <module>
    from .classifier import create_classifier, ClassifierHead, NormMlpClassifierHead, ClNormMlpClassifierHead
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/timm/layers/classifier.py", line 15, in <module>
    from .create_norm import get_norm_layer
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/timm/layers/create_norm.py", line 14, in <module>
    from torchvision.ops.misc import FrozenBatchNorm2d
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/torchvision/__init__.py", line 10, in <module>
    from torchvision import _meta_registrations, datasets, io, models, ops, transforms, utils  # usort:skip
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/torchvision/_meta_registrations.py", line 164, in <module>
    def meta_nms(dets, scores, iou_threshold):
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/torch/library.py", line 828, in register
    use_lib._register_fake(op_name, func, _stacklevel=stacklevel + 1)
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/torch/library.py", line 198, in _register_fake
    handle = entry.fake_impl.register(func_to_register, source)
  File "/home/bdck/PROJECTS/semantic_segmentation/venv_sem_seg/lib/python3.10/site-packages/torch/_library/fake_impl.py", line 31, in register
    if torch._C._dispatch_has_kernel_for_dispatch_key(self.qualname, "Meta"):
RuntimeError: operator torchvision::nms does not exist

Again thanks for the quick help.

Hi

It might be a incompatible problem
Since latest torchvsion prebuilt wheel still work on it, you need to build torch 2.5.1from source.
Please refer user’s topic and official site to install v2.5.1 pytorch version to be compatible with torchvision.

Thanks