官网: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 pipDownloading pip-21.3.1-py3-none-any.whl (1.7 MB)|████████████████████████████████| 1.7 MB 515 kB/s
Installing collected packages: pipAttempting uninstall: pipFound existing installation: pip 21.3.1Uninstalling 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.0Downloading torch-1.2.0-cp36-cp36m-manylinux1_x86_64.whl (748.8 MB)|████████████████████████████████| 748.8 MB 42 kB/s
Collecting torchvision==0.4.0Downloading 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