conda 安装pytorch新环境

1. 创建环境

conda create -n pytorch1.7.1 python=3.7

2. 安装pytorch

安装pytorch官网上面安装指令
https://pytorch.org/get-started/previous-versions/

conda install pytorch==1.7.1 torchvision==0.8.2  cudatoolkit=11.0 -c pytorch  ##torchaudio==0.7.2  语言的不需要

import torch的时候报错

(pytorch1.7.1) admin@admin-System-Product-Name:~$ python
Python 3.7.16 (default, Jan 17 2023, 22:20:44) 
[GCC 11.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/media/algo/data_1/software/anconda_install/envs/pytorch1.7.1/lib/python3.7/site-packages/torch/__init__.py", line 189, in <module>
    _load_global_deps()
  File "/media/algo/data_1/software/anconda_install/envs/pytorch1.7.1/lib/python3.7/site-packages/torch/__init__.py", line 142, in _load_global_deps
    ctypes.CDLL(lib_path, mode=ctypes.RTLD_GLOBAL)
  File "/media/algo/data_1/software/anconda_install/envs/pytorch1.7.1/lib/python3.7/ctypes/__init__.py", line 364, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /media/algo/data_1/software/anconda_install/envs/pytorch1.7.1/lib/python3.7/site-packages/torch/lib/../../../../libcublas.so.11: symbol free_gemm_select version libcublasLt.so.11 not defined in file libcublasLt.so.11 with link time reference

卸载

conda uninstall pytorch==1.7.1

查看安装的库

conda list

用pip 安装torch

pip install torch==1.7.1+cu110 torchvision==0.8.2+cu110  -f https://download.pytorch.org/whl/torch_stable.html

测试

(pytorch1.7.1) admin@admin-System-Product-Name:~$ python
Python 3.7.16 (default, Jan 17 2023, 22:20:44) 
[GCC 11.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.cuda.is_available()
True
>>> torch.version.cuda
'11.0'
>>> torch.backends.cudnn.is_available()
True
>>> torch.backends.cudnn.version() 
8005
>>> 

posted @ 2023-05-06 13:41  无左无右  阅读(1346)  评论(0编辑  收藏  举报