安装Pytorch、torchvision

官网:https://pytorch.org/get-started/previous-versions/
CUDA:10.2
Cudnn:7.6.5

使用pip:

在这里插入图片描述
卸载

pip uninstall torch
pip uninstall torchvision

以下是cuda10.0出现的问题

xzx@xzx-HP-Z2-Mini-G4-Workstation:~$ sudo python3 get-pip.py
[sudo] xzx 的密码: 
1
WARNING: The directory '/home/xzx/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.
Collecting pip
  Downloading pip-21.3.1-py3-none-any.whl (1.7 MB)
     |████████████████████████████████| 1.7 MB 515 kB/s            
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 21.3.1
    Uninstalling pip-21.3.1:
      Successfully uninstalled pip-21.3.1
Successfully installed pip-21.3.1
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
xzx@xzx-HP-Z2-Mini-G4-Workstation:~$ 1
1:未找到命令
xzx@xzx-HP-Z2-Mini-G4-Workstation:~$ pip -V
bash: /home/xzx/.local/bin/pip: 没有那个文件或目录
xzx@xzx-HP-Z2-Mini-G4-Workstation:~$ pip install torch==1.2.0 torchvision==0.4.0bash: /home/xzx/.local/bin/pip: 没有那个文件或目录
xzx@xzx-HP-Z2-Mini-G4-Workstation:~$ which pip
/usr/local/bin/pip
xzx@xzx-HP-Z2-Mini-G4-Workstation:~$ type pip
pip 已被录入哈希表 (/home/xzx/.local/bin/pip)
xzx@xzx-HP-Z2-Mini-G4-Workstation:~$ hash -r
xzx@xzx-HP-Z2-Mini-G4-Workstation:~$ pip --version
pip 21.3.1 from /usr/local/lib/python3.6/dist-packages/pip (python 3.6)
xzx@xzx-HP-Z2-Mini-G4-Workstation:~$ pip install torch==1.2.0 torchvision==0.4.0Defaulting to user installation because normal site-packages is not writeable
Collecting torch==1.2.0
  Downloading torch-1.2.0-cp36-cp36m-manylinux1_x86_64.whl (748.8 MB)
     |████████████████████████████████| 748.8 MB 42 kB/s              
Collecting torchvision==0.4.0
  Downloading torchvision-0.4.0-cp36-cp36m-manylinux1_x86_64.whl (8.8 MB)
     |████████████████████████████████| 8.8 MB 672 kB/s            
Requirement already satisfied: numpy in /usr/lib/python3/dist-packages (from torch==1.2.0) (1.13.3)
Requirement already satisfied: pillow>=4.1.1 in /usr/lib/python3/dist-packages (from torchvision==0.4.0) (5.1.0)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from torchvision==0.4.0) (1.11.0)
Installing collected packages: torch, torchvision
Successfully installed torch-1.2.0 torchvision-0.4.0
xzx@xzx-HP-Z2-Mini-G4-Workstation:~$ 
其中pip报了个错:

```python
Traceback (most recent call last):
  File "/home/xzx/.local/bin/pip", line 7, in <module>
    from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip._internal'

参考:

https://blog.csdn.net/qq_40660130/article/details/116227790
https://blog.csdn.net/Wjhsmart/article/details/107918956

两篇文章解决了:

wget https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py
pip -V

error:

xzx@xzx-HP-Z2-Mini-G4-Workstation:~$ pip -V
bash: /home/xzx/.local/bin/pip: 没有那个文件或目录

解决:

这个应该是不小心把pip删掉的原因导致的,所以需要重新配置一下。先执行下面命令。

which pip

再执行下面的命令。

type pip
最后执行以下命令。这个命令很重要,不执行这个命令不会刷新哈希值。

hash -r

再次执行下面命令就会发现已经好了。

pip --version
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

cashapxxx

你的鼓励将是我创作的最大动力

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

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

打赏作者

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

抵扣说明:

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

余额充值