Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[solve]Exception: path is on mount 'C:', start on mount 'D:'. Cache may be out of date, #6976

Closed
2 tasks done
polarbear0827 opened this issue Mar 14, 2022 · 13 comments · Fixed by #7158
Closed
2 tasks done
Labels
bug Something isn't working

Comments

@polarbear0827
Copy link

Search before asking

  • I have searched the YOLOv5 issues and found no similar bug report.

YOLOv5 Component

Detection

Bug

D:\Users\a5201\yolococogpu01\venv\Scripts\python.exe D:/Users/a5201/yolococogpu01/detect01.py
Downloading: "https://github.com/ultralytics/yolov5/archive/master.zip" to C:\Users\USER/.cache\torch\hub\master.zip
fatal: not a git repository (or any of the parent directories): .git
YOLOv5 2022-3-14 torch 1.8.2+cu111 CUDA:0 (NVIDIA GeForce GTX 950M, 2048MiB)

Traceback (most recent call last):
File "C:\Users\USER/.cache\torch\hub\ultralytics_yolov5_master\hubconf.py", line 46, in _create
model = DetectMultiBackend(path, device=device) # download/load FP32 model
File "C:\Users\USER/.cache\torch\hub\ultralytics_yolov5_master\models\common.py", line 297, in init
pt, jit, onnx, xml, engine, coreml, saved_model, pb, tflite, edgetpu, tfjs = self.model_type(w) # get backend
File "C:\Users\USER/.cache\torch\hub\ultralytics_yolov5_master\models\common.py", line 475, in model_type
from export import export_formats
File "C:\Users\USER/.cache\torch\hub\ultralytics_yolov5_master\export.py", line 64, in
ROOT = Path(os.path.relpath(ROOT, Path.cwd())) # relative
File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\ntpath.py", line 703, in relpath
raise ValueError("path is on mount %r, start on mount %r" % (
ValueError: path is on mount 'C:', start on mount 'D:'

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

Traceback (most recent call last):
File "D:\Users\a5201\yolococogpu01\detect01.py", line 5, in
model = torch.hub.load("ultralytics/yolov5", "custom", path = "yolov5/runs/train/exp34/weights/best.pt", force_reload=True ).autoshape()
File "D:\Users\a5201\yolococogpu01\venv\lib\site-packages\torch\hub.py", line 339, in load
model = _load_local(repo_or_dir, model, *args, **kwargs)
File "D:\Users\a5201\yolococogpu01\venv\lib\site-packages\torch\hub.py", line 368, in _load_local
model = entry(*args, **kwargs)
File "C:\Users\USER/.cache\torch\hub\ultralytics_yolov5_master\hubconf.py", line 70, in custom
return _create(path, autoshape=autoshape, verbose=verbose, device=device)
File "C:\Users\USER/.cache\torch\hub\ultralytics_yolov5_master\hubconf.py", line 65, in _create
raise Exception(s) from e
Exception: path is on mount 'C:', start on mount 'D:'. Cache may be out of date, try force_reload=True or see #36 for help.

Process finished with exit code 1

Environment

YOLOv5 2022-3-14 torch 1.8.2+cu111 CUDA:0 (NVIDIA GeForce GTX 950M, 2048MiB)
Python3.9

Minimal Reproducible Example

No response

Additional

code:
import torch
import cv2
import numpy as np

model = torch.hub.load("ultralytics/yolov5", "custom", path = "yolov5/runs/train/exp34/weights/best.pt", force_reload=True )

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!
@polarbear0827 polarbear0827 added the bug Something isn't working label Mar 14, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Mar 14, 2022

👋 Hello @polarbear0827, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

For business inquiries or professional support requests please visit https://ultralytics.com or email support@ultralytics.com.

Requirements

Python>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started:

git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), validation (val.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

@quangdungluong
Copy link

I have the same problem as you. The possible reason for this error is the os.relpath does not give you a relative path between two directories. I tried load model by clone the repo and load local and it works.
model = torch.hub.load(path/to/yolov5, 'custom', path=path/to/your/model ,source='local')
You also avoid this problem by copying your app to C: drive, selecting your python interpreter and trying to execute the code again.

@polarbear0827
Copy link
Author

Is it changed to this?

model = torch.hub.load("C:/Users/USER/.cache/torch/hub/ultralytics_yolov5_master", "custom", path = "D:/Users/a5201/olococogpu01/yolov5/runs/train/exp34/weights/best.pt", force_reload=True )

@polarbear0827
Copy link
Author

it produces another error

D:\Users\a5201\yolococogpu01\venv\Scripts\python.exe D:/Users/a5201/yolococogpu01/detect01.py
Traceback (most recent call last):
File "D:\Users\a5201\yolococogpu01\detect01.py", line 5, in
model = torch.hub.load("C:/Users/USER/.cache/torch/hub/ultralytics_yolov5_master", "custom", path = "D:/Users/a5201/olococogpu01/yolov5/runs/train/exp34/weights/best.pt", force_reload=True )
File "D:\Users\a5201\yolococogpu01\venv\lib\site-packages\torch\hub.py", line 337, in load
repo_or_dir = _get_cache_or_reload(repo_or_dir, force_reload, verbose)
File "D:\Users\a5201\yolococogpu01\venv\lib\site-packages\torch\hub.py", line 121, in _get_cache_or_reload
repo_owner, repo_name, branch = _parse_repo_info(github)
File "D:\Users\a5201\yolococogpu01\venv\lib\site-packages\torch\hub.py", line 111, in _parse_repo_info
repo_owner, repo_name = repo_info.split('/')
ValueError: not enough values to unpack (expected 2, got 1)

@quangdungluong
Copy link

Is it changed to this?

model = torch.hub.load("C:/Users/USER/.cache/torch/hub/ultralytics_yolov5_master", "custom", path = "D:/Users/a5201/olococogpu01/yolov5/runs/train/exp34/weights/best.pt", force_reload=True )

I haven't tried it. I cloned yolov5 repo and it works.

@quangdungluong
Copy link

it produces another error

D:\Users\a5201\yolococogpu01\venv\Scripts\python.exe D:/Users/a5201/yolococogpu01/detect01.py

Traceback (most recent call last):

File "D:\Users\a5201\yolococogpu01\detect01.py", line 5, in

model = torch.hub.load("C:/Users/USER/.cache/torch/hub/ultralytics_yolov5_master", "custom", path = "D:/Users/a5201/olococogpu01/yolov5/runs/train/exp34/weights/best.pt", force_reload=True )

File "D:\Users\a5201\yolococogpu01\venv\lib\site-packages\torch\hub.py", line 337, in load

repo_or_dir = _get_cache_or_reload(repo_or_dir, force_reload, verbose)

File "D:\Users\a5201\yolococogpu01\venv\lib\site-packages\torch\hub.py", line 121, in _get_cache_or_reload

repo_owner, repo_name, branch = _parse_repo_info(github)

File "D:\Users\a5201\yolococogpu01\venv\lib\site-packages\torch\hub.py", line 111, in _parse_repo_info

repo_owner, repo_name = repo_info.split('/')

ValueError: not enough values to unpack (expected 2, got 1)

remember "source=local"

@polarbear0827
Copy link
Author

polarbear0827 commented Mar 14, 2022

i'd like to apologize for my forgot that, but it still error

model = torch.hub.load("C:/Users/USER/.cache/torch/hub/ultralytics_yolov5_master", "custom", path = "D:/Users/a5201/olococogpu01/yolov5/runs/train/exp34/weights/best.pt", source='local' )

fatal: not a git repository (or any of the parent directories): .git
YOLOv5 2022-3-14 torch 1.8.2+cu111 CUDA:0 (NVIDIA GeForce GTX 950M, 2048MiB)

Traceback (most recent call last):
File "C:/Users/USER/.cache/torch/hub/ultralytics_yolov5_master\hubconf.py", line 46, in _create
model = DetectMultiBackend(path, device=device) # download/load FP32 model
File "C:/Users/USER/.cache/torch/hub/ultralytics_yolov5_master\models\common.py", line 297, in init
pt, jit, onnx, xml, engine, coreml, saved_model, pb, tflite, edgetpu, tfjs = self.model_type(w) # get backend
File "C:/Users/USER/.cache/torch/hub/ultralytics_yolov5_master\models\common.py", line 476, in model_type
from export import export_formats
File "C:/Users/USER/.cache/torch/hub/ultralytics_yolov5_master\export.py", line 64, in
ROOT = Path(os.path.relpath(ROOT, Path.cwd())) # relative
File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\ntpath.py", line 703, in relpath
raise ValueError("path is on mount %r, start on mount %r" % (
ValueError: path is on mount 'C:', start on mount 'D:'

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

Traceback (most recent call last):
File "D:\Users\a5201\yolococogpu01\detect01.py", line 5, in
model = torch.hub.load("C:/Users/USER/.cache/torch/hub/ultralytics_yolov5_master", "custom", path = "D:/Users/a5201/olococogpu01/yolov5/runs/train/exp34/weights/best.pt", source='local' )
File "D:\Users\a5201\yolococogpu01\venv\lib\site-packages\torch\hub.py", line 339, in load
model = _load_local(repo_or_dir, model, *args, **kwargs)
File "D:\Users\a5201\yolococogpu01\venv\lib\site-packages\torch\hub.py", line 368, in _load_local
model = entry(*args, **kwargs)
File "C:/Users/USER/.cache/torch/hub/ultralytics_yolov5_master\hubconf.py", line 70, in custom
return _create(path, autoshape=autoshape, verbose=verbose, device=device)
File "C:/Users/USER/.cache/torch/hub/ultralytics_yolov5_master\hubconf.py", line 65, in _create
raise Exception(s) from e
Exception: path is on mount 'C:', start on mount 'D:'. Cache may be out of date, try force_reload=True or see https://docs.ultralytics.com/yolov5/tutorials/pytorch_hub_model_loading for help.

Process finished with exit code 1

@quangdungluong
Copy link

quangdungluong commented Mar 14, 2022

Lets try clone yolov5 repo and copy path. It works for me

@polarbear0827
Copy link
Author

I clone yolov5 and the problem still occurs

@polarbear0827 polarbear0827 changed the title Exception: path is on mount 'C:', start on mount 'D:'. Cache may be out of date, [slove]Exception: path is on mount 'C:', start on mount 'D:'. Cache may be out of date, Mar 15, 2022
@polarbear0827 polarbear0827 changed the title [slove]Exception: path is on mount 'C:', start on mount 'D:'. Cache may be out of date, [solve]Exception: path is on mount 'C:', start on mount 'D:'. Cache may be out of date, Mar 15, 2022
@polarbear0827
Copy link
Author

Move entire file to C folder, It can be solved

@wonderfuer
Copy link

In general, allocate a directory on Disk C to be used as the running directory of the API site, and then copy restapi.py to solve the problem.

@glenn-jocher glenn-jocher linked a pull request Mar 26, 2022 that will close this issue
@glenn-jocher
Copy link
Member

@polarbear0827 @quangdungluong @CHENZHIKANG I have a proposed fix PR implemented in #7158. Can you please test the PR with this command? If it works I'll merge into master, if it doesn't work please paste your new error message. Thanks!

import torch

model = torch.hub.load('ultralytics/yolov5:fix/relpath', 'yolov5s', force_reload=True)

@glenn-jocher
Copy link
Member

@polarbear0827 @quangdungluong @CHENZHIKANG good news 😃! Your original issue may now be fixed ✅ in PR #7158. To receive this update:

  • Gitgit pull from within your yolov5/ directory or git clone https://github.com/ultralytics/yolov5 again
  • PyTorch Hub – Force-reload model = torch.hub.load('ultralytics/yolov5', 'yolov5s', force_reload=True)
  • Notebooks – View updated notebooks Open In Colab Open In Kaggle
  • Dockersudo docker pull ultralytics/yolov5:latest to update your image Docker Pulls

Thank you for spotting this issue and informing us of the problem. Please let us know if this update resolves the issue for you, and feel free to inform us of any other issues you discover or feature requests that come to mind. Happy trainings with YOLOv5 🚀!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants