卸载 PyTorch

卸载 PyTorch

https://github.com/pytorch/pytorch/blob/master/CONTRIBUTING.md

To reinstall, first uninstall all existing PyTorch installs. You may need to run pip uninstall torch multiple times. You’ll know torch is fully uninstalled when you see WARNING: Skipping torch as it is not installed. (You should only have to pip uninstall a few times, but you can always uninstall with timeout or in a loop if you’re feeling lazy.)

conda uninstall pytorch -y
yes | pip uninstall torch

Uninstall all existing PyTorch installs:

conda uninstall pytorch
pip uninstall torch
pip uninstall torch # run this command twice
yongqiang@strong-sys:~$ pip uninstall torch
Uninstalling torch-1.0.0a0+46ef2b2:
  Would remove:
    /usr/local/lib/python2.7/dist-packages/caffe2
    /usr/local/lib/python2.7/dist-packages/torch
    /usr/local/lib/python2.7/dist-packages/torch-1.0.0a0+46ef2b2.egg-info
Proceed (y/n)? y
Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/cli/base_command.py", line 143, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/commands/uninstall.py", line 75, in run
    auto_confirm=options.yes, verbose=self.verbosity > 0,
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/req/req_install.py", line 683, in uninstall
    uninstalled_pathset.remove(auto_confirm, verbose)
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/req/req_uninstall.py", line 224, in remove
    renames(path, new_path)
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/utils/misc.py", line 280, in renames
    shutil.move(old, new)
  File "/usr/lib/python2.7/shutil.py", line 300, in move
    rmtree(src)
  File "/usr/lib/python2.7/shutil.py", line 247, in rmtree
    rmtree(fullname, ignore_errors, onerror)
  File "/usr/lib/python2.7/shutil.py", line 252, in rmtree
    onerror(os.remove, fullname, sys.exc_info())
  File "/usr/lib/python2.7/shutil.py", line 250, in rmtree
    os.remove(fullname)
OSError: [Errno 13] 权限不够: '/usr/local/lib/python2.7/dist-packages/caffe2/proto/metanet_pb2.py'
yongqiang@strong-sys:~$


yongqiang@strong-sys:~$ sudo pip uninstall torch
[sudo] yongqiang 的密码: 
The directory '/home/yongqiang/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Uninstalling torch-1.0.0a0+46ef2b2:
  Would remove:
    /usr/local/lib/python2.7/dist-packages/caffe2
    /usr/local/lib/python2.7/dist-packages/torch
    /usr/local/lib/python2.7/dist-packages/torch-1.0.0a0+46ef2b2.egg-info
Proceed (y/n)? y
  Successfully uninstalled torch-1.0.0a0+46ef2b2
yongqiang@strong-sys:~$


yongqiang@strong-sys:~$ sudo pip uninstall torch
The directory '/home/yongqiang/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Skipping torch as it is not installed.
yongqiang@strong-sys:~$ 


yongqiang@strong-sys:~$ python
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import torchvision
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/torchvision/__init__.py", line 1, in <module>
    from torchvision import models
  File "/usr/local/lib/python2.7/dist-packages/torchvision/models/__init__.py", line 1, in <module>
    from .alexnet import *
  File "/usr/local/lib/python2.7/dist-packages/torchvision/models/alexnet.py", line 1, in <module>
    import torch.nn as nn
ImportError: No module named torch.nn
>>> exit()
yongqiang@strong-sys:~$ 
yongqiang@famu-sys:~$ sudo pip uninstall torch
yongqiang@famu-sys:~$ sudo pip3 uninstall torch
yongqiang@famu-sys:~$ sudo pip uninstall torch
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
WARNING: The directory '/home/yongqiang/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Uninstalling torch-1.0.1.post2:
  Would remove:
    /usr/local/bin/convert-caffe2-to-onnx
    /usr/local/bin/convert-onnx-to-caffe2
    /usr/local/lib/python2.7/dist-packages/caffe2/*
    /usr/local/lib/python2.7/dist-packages/torch-1.0.1.post2.dist-info/*
    /usr/local/lib/python2.7/dist-packages/torch/*
Proceed (y/n)? y
  Successfully uninstalled torch-1.0.1.post2
yongqiang@famu-sys:~$

yongqiang@famu-sys:~$ sudo pip3 uninstall torch
WARNING: The directory '/home/yongqiang/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Uninstalling torch-1.1.0:
  Would remove:
    /usr/local/lib/python3.5/dist-packages/caffe2/*
    /usr/local/lib/python3.5/dist-packages/torch-1.1.0.dist-info/*
    /usr/local/lib/python3.5/dist-packages/torch/*
Proceed (y/n)? y
  Successfully uninstalled torch-1.1.0
yongqiang@famu-sys:~$

References

[1] Yongqiang Cheng, https://yongqiang.blog.csdn.net/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Yongqiang Cheng

梦想不是浮躁,而是沉淀和积累。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值