Hi Jun :
it is still error :the following is log & config
python 3.10.19 torch 1.13.0 torchvison 0.14.0 ultralytics 8.0.111 numpy 1.26.0 opencv-python 4.10.0.84
(yolov8) ubuntu@ubuntu:~/neuropilot/yolov5$ python3 export.py --weights yolov8s.pt --img-size 640 640 --include torchscript
/home/ubuntu/neuropilot/yolov5/utils/general.py:34: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
import pkg_resources as pkg
export: data=data/coco128.yaml, weights=[‘yolov8s.pt’], imgsz=[640, 640], batch_size=1, device=cpu, half=False, inplace=False, keras=False, optimize=False, int8=False, dynamic=False, simplify=False, opset=17, verbose=False, workspace=4, nms=False, agnostic_nms=False, topk_per_class=100, topk_all=100, iou_thres=0.45, conf_thres=0.25, include=[‘torchscript’]
YOLOv5 v7.0-193-g485da422 Python-3.10.19 torch-2.12.1+cu130 CPU
Traceback (most recent call last):
File “/home/ubuntu/neuropilot/yolov5/export.py”, line 863, in
main(opt)
File “/home/ubuntu/neuropilot/yolov5/export.py”, line 858, in main
run(**vars(opt))
File “/home/ubuntu/anaconda3/envs/yolov8/lib/python3.10/site-packages/torch/utils/_contextlib.py”, line 124, in decorate_context
return func(*args, **kwargs)
File “/home/ubuntu/neuropilot/yolov5/export.py”, line 736, in run
model = attempt_load(weights, device=device, inplace=True, fuse=True) # load FP32 model
File “/home/ubuntu/neuropilot/yolov5/models/experimental.py”, line 79, in attempt_load
ckpt = torch.load(attempt_download(w), map_location=‘cpu’) # load
File “/home/ubuntu/anaconda3/envs/yolov8/lib/python3.10/site-packages/torch/serialization.py”, line 1578, in load
raise pickle.UnpicklingError(_get_wo_message(str(e))) from None
_pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, do those steps only if you trust the source of the checkpoint.
(1) In PyTorch 2.6, we changed the default value of the weights_only argument in torch.load from False to True. Re-running torch.load with weights_only set to False will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
(2) Alternatively, to load with weights_only=True please check the recommended steps in the following error message.
WeightsUnpickler error: Unsupported global: GLOBAL ultralytics.nn.tasks.DetectionModel was not an allowed global by default. Please use torch.serialization.add_safe_globals([ultralytics.nn.tasks.DetectionModel]) or the torch.serialization.safe_globals([ultralytics.nn.tasks.DetectionModel]) context manager to allowlist this global if you trust this class/function.
Check the documentation of torch.load to learn more about types accepted by default with weights_only Redirecting… .
(yolov8) ubuntu@ubuntu:~/neuropilot/yolov5$ pip show torch torchvision ultralytics opencv-python
Name: torch
Version: 1.13.0
Summary: Tensors and Dynamic neural networks in Python with strong GPU acceleration
Home-page: https://pytorch.org/
Author: PyTorch Team
Author-email: packages@pytorch.org
License: BSD-3
Location: /home/ubuntu/anaconda3/envs/yolov8/lib/python3.10/site-packages
Requires: nvidia-cublas-cu11, nvidia-cuda-nvrtc-cu11, nvidia-cuda-runtime-cu11, nvidia-cudnn-cu11, typing-extensions
Required-by: thop, torchvision, ultralytics, ultralytics-thop
Name: torchvision
Version: 0.14.0
Summary: image and video datasets and models for torch deep learning
Home-page: GitHub - pytorch/vision: Datasets, Transforms and Models specific to Computer Vision · GitHub
Author: PyTorch Core Team
Author-email: soumith@pytorch.org
License: BSD
Location: /home/ubuntu/anaconda3/envs/yolov8/lib/python3.10/site-packages
Requires: numpy, pillow, requests, torch, typing-extensions
Required-by: ultralytics
Name: ultralytics
Version: 8.0.111
Summary: Ultralytics YOLOv8 for SOTA object detection, multi-object tracking, instance segmentation, pose estimation and image classification.
Home-page: GitHub - ultralytics/ultralytics: Ultralytics YOLO26, YOLO11, YOLOv8 — object detection, instance segmentation, semantic segmentation, image classification, pose estimation, object tracking · GitHub
Author: Ultralytics
Author-email: hello@ultralytics.com
License: AGPL-3.0
Location: /home/ubuntu/anaconda3/envs/yolov8/lib/python3.10/site-packages
Requires: matplotlib, opencv-python, pandas, Pillow, psutil, PyYAML, requests, scipy, seaborn, torch, torchvision, tqdm
Required-by:
Name: opencv-python
Version: 4.10.0.84
Summary: Wrapper package for OpenCV python bindings.
Home-page: GitHub - opencv/opencv-python: Automated CI toolchain to produce precompiled opencv-python, opencv-python-headless, opencv-contrib-python and opencv-contrib-python-headless packages. · GitHub
Author:
Author-email:
License: Apache 2.0
Location: /home/ubuntu/anaconda3/envs/yolov8/lib/python3.10/site-packages
Requires: numpy
Required-by: ultralytics
(yolov8) ubuntu@ubuntu:~/neuropilot/yolov5$ pip show numpy
Name: numpy
Version: 1.26.
(yolov8) ubuntu@ubuntu:~/neuropilot/yolov5$ python3 --version
Python 3.10.19