windows远程连接虚拟机,nfs共享文件夹挂载虚拟机文件夹至windows目录下(文件保存位置为windows)

1.ModuleNotFoundError: No module named 'ultralytics'

在Xshell里面运行python train.py

报错

解决:参考ModuleNotFoundError: No module named 'xxx'可能的解决方案大全 - 知乎 

下载了ultralytics包,安装就能运行了

2.FileNotFoundError: [Errno 2] No such file or directory: 'runs/train/exp8/weights'

Traceback (most recent call last):
  File "/home/nephilim/environment/anaconda3/envs/yolov5/lib/python3.7/pathlib.py", line 1273, in mkdir
    self._accessor.mkdir(self, mode)
FileNotFoundError: [Errno 2] No such file or directory: 'runs/train/exp8/weights'

运行时exp文件夹无法生成 ,发现之前的weights文件下面都没有这两个文件:last.pt表示最后的权重,best.pt表示最好的权重

参考https://www.jzljtnc.com/html/0d4.html

原因:

共享文件夹下的文件没有执行的权利,train.py运行后没有权利生成exp文件夹,查看目录下的文件权限,发现很多文件夹都是读写,没有执行权限。

(base) yyt@nephilim-dell:~/nfshareFile/yolov5-master$ ll
total 14809
drwxr-xr-x 12 yyt  yyt      4096 8月   2 11:17 ./
drwxr-xr-x 11 root root     4096 8月   1 16:18 ../
-rwxr-xr-x  1 yyt  yyt      8009 7月  26 10:43 benchmarks.py*
-rw-r--r--  1 yyt  yyt       393 7月  26 10:43 CITATION.cff
drwxr-xr-x  3 yyt  yyt      4096 8月   2 11:17 classify/
-rw-r--r--  1 yyt  yyt      5009 7月  26 10:43 CONTRIBUTING.md
drwxr-xr-x  5 yyt  yyt      4096 8月   2 11:17 data/
-r-sr-xr-x  1 root root       46 8月   2 09:08 desktop.ini*
-rwxr-xr-x  1 yyt  yyt     14320 7月  26 10:43 detect.py*
-rw-r--r--  1 yyt  yyt      3701 7月  26 10:43 .dockerignore
-rwxr-xr-x  1 yyt  yyt     41190 7月  26 10:43 export.py*
-rw-r--r--  1 yyt  yyt        75 7月  26 10:43 .gitattributes
drwxr-xr-x  4 yyt  yyt      4096 8月   1 16:18 .github/
-rw-r--r--  1 yyt  yyt      3998 7月  26 10:43 .gitignore
drwxr-xr-x  4 yyt  yyt      4096 7月  26 16:18 HR_NoSC_data5/
-rwxr-xr-x  1 yyt  yyt      7769 7月  26 10:43 hubconf.py*
drwxr-xr-x  3 yyt  yyt      4096 8月   2 11:17 .idea/
-rw-r--r--  1 yyt  yyt     34523 7月  26 10:43 LICENSE
drwxr-xr-x  5 yyt  yyt      4096 8月   2 11:17 models/
-rw-r--r--  1 yyt  yyt      1814 7月  26 10:43 .pre-commit-config.yaml
drwxr-xr-x  2 yyt  yyt      4096 8月   2 11:17 __pycache__/
-rw-r--r--  1 yyt  yyt     41498 7月  26 10:43 README.md
-rw-r--r--  1 yyt  yyt     40508 7月  26 10:43 README.zh-CN.md
-rwxr-xr-x  1 yyt  yyt      1554 7月  26 10:43 requirements.txt*
drwxr-xr-x  5 yyt  yyt      4096 8月   2 11:17 runs/
drwxr-xr-x  2 yyt  yyt      4096 8月   1 16:18 segment/
-rw-r--r--  1 yyt  yyt      1723 7月  26 10:43 setup.cfg
-rwxr-xr-x  1 yyt  yyt     33898 7月  27 12:24 train.py*
-rw-r--r--  1 yyt  yyt     40917 7月  26 10:43 tutorial.ipynb
drwxr-xr-x  9 yyt  yyt      4096 8月   2 09:36 utils/
-rwxr-xr-x  1 yyt  yyt     20452 7月  26 10:43 val.py*
-rwxr-xr-x  1 yyt  yyt  14808437 7月  26 12:52 yolov5s.pt*

验证:

切换为用户yyt时,该错误消失,但是出现了问题4(ok,I'm fine🙃)

查看该文件的用户权限 ,在nephilim用户的权限下

用yyt用户权限的文件运行时,需要nephilim用户权限的文件创建目录,失败

(yolov5) root@nephilim-dell:/home/yyt/nfshareFile/yolov5-master# ls -l /home/nephilim/environment/anaconda3/envs/yolov5/lib/python3.7/pathlib.py
-rwxrwxrwx 3 nephilim nephilim 50329 7月  27  2021 /home/nephilim/environment/anaconda3/envs/yolov5/lib/python3.7/pathlib.py

尝试:

想办法让它被两个用户使用(之后再尝试)

3.输入ls cd后无响应

错误:输入ls或者cd都无法进入其他目录下,一直停在home目录,无法打开共享目录等

(base) yyt@nephilim-dell:/home$ df -h
^[[A^[[A^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^C
(base) yyt@nephilim-dell:/home$ cd yyt
(base) yyt@nephilim-dell:~$ cd home
-bash: cd: home: No such file or directory
(base) yyt@nephilim-dell:~$ cd /home/yyt/
(base) yyt@nephilim-dell:~$ ls
^C

变化:

(base) yyt@nephilim-dell:~$ cd /home/
(base) yyt@nephilim-dell:/home$ ls -l
total 28
drwxr-xr-x 12 hyp      root      4096 6月  13 09:21 hyp
drwx------  2 root     root     16384 3月   3  2021 lost+found
drwxr-xr-x 88 nephilim nephilim  4096 7月  26 15:04 nephilim
drwxr-xr-x  7 yyt      yyt       4096 8月   2 10:18 yyt
(base) yyt@nephilim-dell:~$ lsattr /home
lsattr: Permission denied While reading flags on /home/lost+found
--------------e----- /home/nephilim
--------------e----- /home/hyp
--------------e----- /home/yyt
(base) yyt@nephilim-dell:~$ 

解决:

恢复etc/sudoers文件,删去yyt ALL=(ALL) ALL,恢复原样

(base) root@nephilim-dell:/home/yyt# ls
nfshareFile  yolov5-master.tar
(base) root@nephilim-dell:/home/yyt# 

4.OSError: [Errno 28] No space left on device: '/home/yyt/.config/Ultralytics'

(yolov5) yyt@nephilim-dell:~/nfshareFile/yolov5-master$ python train.py
Matplotlib created a temporary config/cache directory at /tmp/matplotlib-5df7u5qa because the default path (/home/yyt/.config/matplotlib) is not a writable directory; it is highly recommended to set the MPLCONFIGDIR environment variable to a writable directory, in particular to speed up the import of Matplotlib and to better support multiprocessing.
Traceback (most recent call last):
  File "train.py", line 48, in <module>
    import val as validate  # for end-of-epoch mAP
  File "/home/yyt/nfshareFile/yolov5-master/val.py", line 39, in <module>
    from models.common import DetectMultiBackend
  File "/home/yyt/nfshareFile/yolov5-master/models/common.py", line 28, in <module>
    from utils.dataloaders import exif_transpose, letterbox
  File "/home/yyt/nfshareFile/yolov5-master/utils/dataloaders.py", line 31, in <module>
    from utils.augmentations import (Albumentations, augment_hsv, classify_albumentations, classify_transforms, copy_paste,
  File "/home/yyt/nfshareFile/yolov5-master/utils/augmentations.py", line 15, in <module>
    from utils.general import LOGGER, check_version, colorstr, resample_segments, segment2box, xywhn2xyxy
  File "/home/yyt/nfshareFile/yolov5-master/utils/general.py", line 38, in <module>
    from ultralytics.yolo.utils.checks import check_requirements
  File "/home/nephilim/environment/anaconda3/envs/yolov5/lib/python3.7/site-packages/ultralytics/__init__.py", line 5, in <module>
    from ultralytics.hub import start
  File "/home/nephilim/environment/anaconda3/envs/yolov5/lib/python3.7/site-packages/ultralytics/hub/__init__.py", line 5, in <module>
    from ultralytics.data.utils import HUBDatasetStats
  File "/home/nephilim/environment/anaconda3/envs/yolov5/lib/python3.7/site-packages/ultralytics/data/__init__.py", line 3, in <module>
    from .base import BaseDataset
  File "/home/nephilim/environment/anaconda3/envs/yolov5/lib/python3.7/site-packages/ultralytics/data/base.py", line 18, in <module>
    from ultralytics.utils import DEFAULT_CFG, LOCAL_RANK, LOGGER, NUM_THREADS, TQDM_BAR_FORMAT
  File "/home/nephilim/environment/anaconda3/envs/yolov5/lib/python3.7/site-packages/ultralytics/utils/__init__.py", line 581, in <module>
    USER_CONFIG_DIR = Path(os.getenv('YOLO_CONFIG_DIR', get_user_config_dir()))  # Ultralytics settings dir
  File "/home/nephilim/environment/anaconda3/envs/yolov5/lib/python3.7/site-packages/ultralytics/utils/__init__.py", line 576, in get_user_config_dir
    path.mkdir(parents=True, exist_ok=True)
  File "/home/nephilim/environment/anaconda3/envs/yolov5/lib/python3.7/pathlib.py", line 1273, in mkdir
    self._accessor.mkdir(self, mode)
OSError: [Errno 28] No space left on device: '/home/yyt/.config/Ultralytics'

内存没有空间的意思

显示虚拟机的/home 已满,而挂载的nfs还剩38G,为什么还会没有空间

错误最后一行显示 '/home/yyt/.config/Ultralytics',这个文件夹在我nfs共享文件夹之外

捋一下:因为对方虚拟机(服务器端)没有内存,所以我设置了nfs共享挂载在我的电脑(本机/客户机)下,文件真正存放的位置在我的电脑中。

.config是软件或系统里的配置文件,它包含的设置和配置信息以及不同的程序可以不同的格式存储这些数据,就像电脑中C:\Users\ASUS\.config,那么它产生在home/yyt目录下的原因也是相似的。

尝试:

把/home/yyt文件夹设为我的共享文件夹,这样.config/Ultralytics文件都会存放在我的电脑中,不存在对方电脑不够用的问题

转root权限运行vim /etc/exports,修改如下,参考http://t.csdn.cn/57nWH

 怀疑:

我从虚拟机duan(服务器端)产看的挂载点,文件挂反了吗?

失败,且出现错误6

5.clnt_create: RPC: Unable to receive

clnt_create:RPC:无法接收

(base) root@nephilim-dell:/home/yyt/nfshareFile/yolov5-master# showmount -e 198.168.0.65
clnt_create: RPC: Unable to receive

原因1:

参考http://t.csdn.cn/3vQmk,可能没有关闭防火墙,但我本来就没装防火墙。

(base) root@nephilim-dell:/home/yyt/nfshareFile/yolov5-master# systemctl status firewalld
Unit firewalld.service could not be found.

6.yyt@nephilim-dell:~$

在yyt模式下无法使用任何环境,conda命令不存在___*(  ̄皿 ̄)/#____,

可能是因为共享文件夹变成了yyt,原本的conda环境文件等无法运行,这和之前文件无法运行是一个道理

 

 改回来,删不掉了aaaa

输入mount | grep nfs查看挂载点

发现有4个,把以下三个都关闭

yyt@nephilim-dell:~$ mount | grep nfs
nfsd on /proc/fs/nfsd type nfsd (rw,relatime)
192.168.0.65:/nfs on /home/yyt/nfshareFile type nfs (rw,relatime,vers=3,rsize=8192,wsize=8192,namlen=255,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=192.168.0.65,mountvers=3,mountport=1058,mountproto=udp,local_lock=all,addr=192.168.0.65)
192.168.0.65:/nfs on /home/yyt type nfs (rw,relatime,vers=3,rsize=8192,wsize=8192,namlen=255,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=192.168.0.65,mountvers=3,mountport=1058,mountproto=udp,local_lock=all,addr=192.168.0.65)
192.168.0.65:/nfs on /home/yyt/nfshareFile type nfs (rw,relatime,vers=3,rsize=8192,wsize=8192,namlen=255,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=192.168.0.65,mountvers=3,mountport=1058,mountproto=udp,local_lock=all,addr=192.168.0.65)

设置sudo权限

没这个权限,有没有密码,但是它老让我输,烦死了

参考http://t.csdn.cn/9cuFL 

切换到root用户,命令行输入visudo

添加如下指令

yyt     ALL=(ALL:ALL)  NOPASSWD:ALL

 无法退出,采用如下指令查看文件权限,发现不能修改

yyt@nephilim-dell:~$    ls -l /etc/sudoers
-r--r----- 1 root root 829 8月   2 11:04 /etc/sudoers

 添加修改的权限(http://t.csdn.cn/Thw0m),成功

chmod 660 /etc/sudoers
(base) root@nephilim-dell:~# ls -l /etc/sudoers
-rw-rw---- 1 root root 829 8月   2 11:04 /etc/sudoers

visudo页面下方出现Recording a macro... ]快捷键指令,依旧无法退出

 参考http://t.csdn.cn/sIbW6

保存:执行“Ctrl+O”,执行完后,会输出”File Name to Write sudoers.tmp”,在tmp后执行回车。

退出:执行“Ctrl+X”

输入 sudo umount /home/yyt/nfshareFile,该文件夹下的东西都被删除了

(base) root@nephilim-dell:~# cd /home/yyt
(base) root@nephilim-dell:/home/yyt# ls
 7-Zip   Anaconda3   cudnn-windows-x86_64-8.9.2.26_cuda11-archive   datasets   JetBrains   nfshareFile  'NVIDA GPU Computing Tooltik'   NVIDIA   VOC2007   yolov5-master
(base) root@nephilim-dell:/home/yyt# cd nfshareFile
(base) root@nephilim-dell:/home/yyt/nfshareFile# ls
(base) root@nephilim-dell:/home/yyt/nfshareFile# 

sudo umount /home/yyt
umount.nfs: /home/yyt: device is busy

删除另一个路径时显示它正在使用

 根据http://t.csdn.cn/yrDkf,杀死使用的文件进程,输入指令 kill -9 kernel(数字编码)

        USER        PID ACCESS COMMAND
/home/yyt:           root     kernel mount /home/yyt/nfshareFile
                     yyt       829658 F...m pulseaudio
                     yyt       829660 F.c.m tracker-miner-f
                     yyt       829667 ..c.. dbus-daemon
                     yyt       829688 ..c.. gvfsd
                     yyt       829693 ..c.. gvfsd-fuse
                     yyt       829709 ..c.. gvfs-udisks2-vo
                     yyt       829800 ..c.. bash
                     yyt       829805 ..c.. gvfs-afc-volume
                     yyt       829810 ..c.. gvfs-goa-volume
                     yyt       829814 ..c.. goa-daemon
                     yyt       829821 ..c.. goa-identity-se
                     yyt       829828 ..c.. gvfs-gphoto2-vo
                     yyt       829833 ..c.. gvfs-mtp-volume
                     root      829869 ..c.. bash
                     USER        PID ACCESS COMMAND
/home/yyt:           root     kernel mount /home/yyt/nfshareFile

 这两个路径还是没有删干净

(base) nephilim@nephilim-dell:/root$ mount | grep nfs
nfsd on /proc/fs/nfsd type nfsd (rw,relatime)
192.168.0.65:/nfs on /home/yyt/nfshareFile type nfs (rw,relatime,vers=3,rsize=8192,wsize=8192,namlen=255,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=192.168.0.65,mountvers=3,mountport=1058,mountproto=udp,local_lock=all,addr=192.168.0.65)
192.168.0.65:/nfs on /home/yyt type nfs (rw,relatime,vers=3,rsize=8192,wsize=8192,namlen=255,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=192.168.0.65,mountvers=3,mountport=1058,mountproto=udp,local_lock=all,addr=192.168.0.65)

 用sudo umount继续删除,但是报错显示挂载点不存在

(base) nephilim@nephilim-dell:/root$ sudo umount -f -l 192.168.0.65:/nfs on /home/yyt/nfshareFile
[sudo] password for nephilim: 
umount: on: no mount point specified.
(base) nephilim@nephilim-dell:/root$ sudo umount -f -l 192.168.0.65:/nfs on /home/yyt
umount: 192.168.0.65:/nfs: no mount point specified.
umount: on: no mount point specified.
umount: /home/yyt: not mounted.

再次,更改用户,yyt下的base环境回来了,且nfs挂载目录删除干净

(base) yyt@nephilim-dell:/root$ 
(base) yyt@nephilim-dell:/root$ fuser -mv /home/yyt
                     USER        PID ACCESS COMMAND
/home/yyt:           root     kernel mount /home
(base) yyt@nephilim-dell:/root$  mount | grep nfs
nfsd on /proc/fs/nfsd type nfsd (rw,relatime)

7.mkdir: cannot create directory ‘/home/yyt/nfshare’: Permission denied

8.sudo:command not found

yyt@nephilim-dell:/root$ sudo yyt
sudo: yyt: command not found
yyt@nephilim-dell:/root$ sudo root
sudo: root: command not found

 暂时先不动

9.同一个文件夹,不同用户看到的文件不一样,默认显示的路径也不一样

(base) root@nephilim-dell:~# 
(base) root@nephilim-dell:~# cd /home/yyt/yyt/
(base) root@nephilim-dell:/home/yyt/yyt# ls
nfshare
(base) root@nephilim-dell:/home/yyt/yyt# 
(base) yyt@nephilim-dell:~/yyt$ 
(base) yyt@nephilim-dell:~/yyt$ cd /home/yyt/yyt/
(base) yyt@nephilim-dell:~/yyt$ ls
nfshare

即root的~目录为home目录,yyt的~目录为/home/yyt

“~” :表示主目录,也就是当前登录用户的用户目录,那么就是两个用户的主目录不同

10.再次挂载nfs

windows下的nfs文件夹目录,这时,它是只读的

 

 systemctl status nfs-server.service 查看nfs状态

● nfs-server.service - NFS server and services
     Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; vendor preset: enabled)
    Drop-In: /run/systemd/generator/nfs-server.service.d
             └─order-with-mounts.conf
     Active: failed (Result: exit-code) since Thu 2023-08-03 15:52:37 CST; 32s ago
    Process: 848771 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=1/FAILURE)
    Process: 848772 ExecStopPost=/usr/sbin/exportfs -au (code=exited, status=0/SUCCESS)
    Process: 848773 ExecStopPost=/usr/sbin/exportfs -f (code=exited, status=0/SUCCESS)

systemctl restart nfs-server.service 重启nfs

Job for nfs-server.service canceled nfs取消了

 systemctl status rpcbind.service 查看rpc,正常

 

 重启:service rpcbind stop

报错显示:8月 03 16:51:09 nephilim-dell exportfs[849726]: exportfs: Failed to stat /~/nfshare: No such file or directory
我的文件压根不在这里,无语

刷新配置

sudo exportfs -r
sudo service nfs restart

文件路径修改成功,然而该路径不支持nfs

 尝试1:

参考exportfs不支持NFS导出

我的文件路径可能是overlay模式,用df -T -h查看,好吧不是它

这个地方本来就有overlay不用在意 

尝试2:

参考http://t.csdn.cn/vlN2V

再次重启nfs,报错:exportfs[861977]: exportfs: Failed to stat /home/yyt/nfshare: Stale file handle

(base) root@nephilim-dell:~# service nfs-kernel-server status
● nfs-server.service - NFS server and services
     Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; vendor preset: enabled)
    Drop-In: /run/systemd/generator/nfs-server.service.d
             └─order-with-mounts.conf
     Active: failed (Result: exit-code) since Fri 2023-08-04 09:22:16 CST; 1min 57s ago
lines 1-5...skipping...
● nfs-server.service - NFS server and services
     Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; vendor preset: enabled)
    Drop-In: /run/systemd/generator/nfs-server.service.d
             └─order-with-mounts.conf
     Active: failed (Result: exit-code) since Fri 2023-08-04 09:22:16 CST; 1min 57s ago
    Process: 861977 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=1/FAILURE)
    Process: 861978 ExecStopPost=/usr/sbin/exportfs -au (code=exited, status=0/SUCCESS)
    Process: 861979 ExecStopPost=/usr/sbin/exportfs -f (code=exited, status=0/SUCCESS)

8月 04 09:22:16 nephilim-dell systemd[1]: Starting NFS server and services...
8月 04 09:22:16 nephilim-dell exportfs[861977]: exportfs: Failed to stat /home/yyt/nfshare: Stale file handle
8月 04 09:22:16 nephilim-dell systemd[1]: nfs-server.service: Control process exited, code=exited, status=1/FAILURE
8月 04 09:22:16 nephilim-dell systemd[1]: nfs-server.service: Failed with result 'exit-code'.
8月 04 09:22:16 nephilim-dell systemd[1]: Stopped NFS server and services.

在/etc/exports文件中,加入fsid=0参数,失败

尝试3

删除挂载点,再次挂载,不行,心好累啊

查询rpc服务注册信息

 /var/lib/nfs/etab      exports table nfs服务端共享列表(nfs服务端的共享信息)

/home/yyt/nfshare       *(rw,sync,wdelay,hide,nocrossmnt,secure,root_squash,no_all_squash,no_subtree_check,secure_locks,acl,no_pnfs,anonuid=65534,anongid=65534,sec=sys,rw,secure,root_squash,no_all_squash)
(base) root@nephilim-dell:/home# ps -A | grep nfs
 617617 ?        00:00:00 nfsiod
 866886 ?        00:00:00 nfsd
 866887 ?        00:00:00 nfsd
 866888 ?        00:00:00 nfsd
 866889 ?        00:00:00 nfsd
 866890 ?        00:00:00 nfsd
 866891 ?        00:00:00 nfsd
 866892 ?        00:00:00 nfsd
 866893 ?        00:00:00 nfsd

NFS的服务器提供三个关键守护进程:portmap,mounted,nfsd

(1)portmap ―― 监听固定端口,提供RPC服务,将TCP/IP的协议端口映射为RPC程序号;

(2) nfsd ―― 根据客户需求启动文件系统请求服务守护进程,处理用户需求;

(3)mounted ―― 发送文件句柄给客户端的mount进程。

其它进程nfsiod:用于提供IO吞吐率

真是混乱的一篇文章

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值