记录ubuntu Anaconda离线安装pytorch

前提:安装cuda,cudnn,anaconda

conda install pytorch==1.9.0 torchvision==0.10.0 torchaudio==0.9.0 cudatoolkit=10.2 -c pytorch

记录ubuntu Anaconda离线安装pytorch_第1张图片
记录ubuntu Anaconda离线安装pytorch_第2张图片
出了清华源,其他几个都是官方地址,很慢,因此选择离线下载,手动安装
安装没有用解压,setup之类的,直接conda intall,前提是进入conda activate你想安装的虚拟环境里面
记录ubuntu Anaconda离线安装pytorch_第3张图片
后续,使用python测试,发现无法引入。

import torch
Traceback (most recent call last):
  File "", line 1, in <module>
  File "/home/zccc/anaconda3/envs/zlg/lib/python3.8/site-packages/torch/__init__.py", line 196, in <module>
    _load_global_deps()
  File "/home/zccc/anaconda3/envs/zlg/lib/python3.8/site-packages/torch/__init__.py", line 149, in _load_global_deps
    ctypes.CDLL(lib_path, mode=ctypes.RTLD_GLOBAL)
  File "/home/zccc/anaconda3/envs/zlg/lib/python3.8/ctypes/__init__.py", line 369, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libmkl_intel_lp64.so: cannot open shared object file: No such file or directory

然后,又运行了一遍:
提示我不一致,不管他

conda install pytorch==1.9.0 torchvision==0.10.0 torchaudio==0.9.0 cudatoolkit=10.2 -c pytorch

The following packages are causing the inconsistency:

  - <unknown>/linux-64::ffmpeg==4.3=hf484d3e_0
  - <unknown>/linux-64::torchvision==0.10.0=py38_cu102
  - <unknown>/linux-64::torchaudio==0.9.0=py38
  - <unknown>/linux-64::pytorch==1.9.0=py3.8_cuda10.2_cudnn7.6.5_0                                                                                                                           done
The following NEW packages will be INSTALLED:

  blas               anaconda/pkgs/free/linux-64::blas-1.0-mkl
  bzip2              anaconda/cloud/conda-forge/linux-64::bzip2-1.0.8-h7f98852_4
  cudatoolkit        anaconda/cloud/conda-forge/linux-64::cudatoolkit-10.2.89-h8f6ccaa_10
  freetype           anaconda/cloud/conda-forge/linux-64::freetype-2.10.4-h0708190_1
  giflib             anaconda/cloud/conda-forge/linux-64::giflib-5.2.1-h36c2ea0_2
  gmp                anaconda/cloud/conda-forge/linux-64::gmp-6.2.1-h58526e2_0
  gnutls             anaconda/cloud/conda-forge/linux-64::gnutls-3.6.13-h85f3911_1
  intel-openmp       anaconda/pkgs/main/linux-64::intel-openmp-2021.4.0-h06a4308_3561
  jpeg               anaconda/pkgs/free/linux-64::jpeg-9b-0
  lame               anaconda/cloud/conda-forge/linux-64::lame-3.100-h7f98852_1001
  lcms2              anaconda/pkgs/main/linux-64::lcms2-2.12-h3be6417_0
  libiconv           anaconda/pkgs/free/linux-64::libiconv-1.14-0
  libpng             anaconda/cloud/conda-forge/linux-64::libpng-1.6.37-h21135ba_2
  libtiff            anaconda/pkgs/main/linux-64::libtiff-4.2.0-h85742a9_0
  libuv              anaconda/cloud/conda-forge/linux-64::libuv-1.43.0-h7f98852_0
  libwebp            anaconda/pkgs/main/linux-64::libwebp-1.2.0-h89dd481_0
  libwebp-base       anaconda/pkgs/main/linux-64::libwebp-base-1.2.0-h27cfd23_0
  lz4-c              anaconda/cloud/conda-forge/linux-64::lz4-c-1.9.3-h9c3ff4c_1
  mkl                anaconda/pkgs/main/linux-64::mkl-2021.4.0-h06a4308_640
  mkl-service        anaconda/cloud/conda-forge/linux-64::mkl-service-2.4.0-py38h95df7f1_0
  mkl_fft            anaconda/cloud/conda-forge/linux-64::mkl_fft-1.3.1-py38h8666266_1
  mkl_random         anaconda/cloud/conda-forge/linux-64::mkl_random-1.2.2-py38h1abd341_0
  nettle             anaconda/cloud/conda-forge/linux-64::nettle-3.6-he412f7d_0
  ninja              anaconda/pkgs/free/linux-64::ninja-1.7.2-0
  numpy              anaconda/pkgs/main/linux-64::numpy-1.21.2-py38h20f2e39_0
  numpy-base         anaconda/pkgs/main/linux-64::numpy-base-1.21.2-py38h79a1101_0
  openh264           anaconda/cloud/conda-forge/linux-64::openh264-2.1.1-h780b84a_0
  pillow             anaconda/pkgs/main/linux-64::pillow-9.0.1-py38h22f2fdc_0
  six                anaconda/cloud/conda-forge/noarch::six-1.16.0-pyh6c4a22f_0
  typing_extensions  anaconda/cloud/conda-forge/noarch::typing_extensions-4.1.1-pyha770c72_0
  zstd               anaconda/cloud/conda-forge/linux-64::zstd-1.4.9-ha95c52a_0


Proceed ([y]/n)? y

Preparing transaction: done
Verifying transaction: done
Executing transaction: | By downloading and using the CUDA Toolkit conda packages, you accept the terms and conditions of the CUDA End User License Agreement (EULA): https://docs.nvidia.com/c               uda/eula/index.html
                                                                                                                                                                                             done

**接着测试:**应该是可以用了

import torch
>>> torch.cuda.is_available()
True
>>> torch.cuda.current_device()
0
>>> torch.cuda.device_count()
1
>>> torch.cuda.get_device_name()
'NVIDIA TITAN RTX'

你可能感兴趣的:(pytorch,ubuntu,linux)