当前位置:   article > 正文

conda 安装pytorch_libgcc-ng

libgcc-ng

先为conda 添加源

编辑home目录下的.condarc文件

如果是windows, 在C:\Users\Administrator

新建一个.conda文件夹,在.conda文件夹新建.condarc文件

或在C:\Users\Administrator这个目录下直接新建.condarc

可以都弄

  1. channels:
  2. - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
  3. - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  4. - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  5. - https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
  6. - https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
  7. - defaults
  8. show_channel_urls: true
  9. remote_read_timeout_secs: 600.0

注意要把https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

写在第一行,因为像https://mirrors.ustc.edu.cn/anaconda/pkgs/main/这个链接或者其他链接

也有pytorch,但有时候会中断,所以把最稳定最快的链接写前面,因为你不写在前面conda在https://mirrors.ustc.edu.cn/anaconda/pkgs/main/这个链接搜索到了pytorch,就不会去https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/这个链接搜,导致中断

换好源之后,然后最好先建一个虚拟环境

conda create -n torch1.2 python=3.6

再执行:

conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0

 

相装1.1的话

conda install pytorch==1.1.0 torchvision==0.3.0 cudatoolkit=9.0

它会自动把其他所有依赖比如cudnn也装,记住后面不要加-c pytorch,要不然就不会走中科大的源

这种用conda装pytorch,就不用手动装cuda,

  中科大这两句也要加,因为cudatoolkit我下载的时候都是在中科大这两个源下载的

- https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/free/

 

 

然后我又想改装pytorch 1.3.1

我就直接conda install pytorch==1.3.1

后续测试

  1. In [1]: import torch
  2. In [2]: torch.__version__
  3. Out[2]: '1.3.1'
  4. In [3]:
  5. In [3]: torch.cuda.is_available()
  6. Out[3]: True

下面是装的时候自动装的一些包:

  1. (pytorch) wosai@wosai:~$ conda list
  2. # packages in environment at /home/wosai/anaconda3/envs/pytorch:
  3. #
  4. # Name Version Build Channel
  5. _libgcc_mutex 0.1 main https://mirrors.ustc.edu.cn/anaconda/pkgs/main
  6. backcall 0.1.0 <pip>
  7. blas 1.0 mkl https://mirrors.ustc.edu.cn/anaconda/pkgs/free
  8. certifi 2016.2.28 py36_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
  9. cffi 1.10.0 py36_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
  10. cudatoolkit 10.0.130 0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
  11. decorator 4.4.1 <pip>
  12. freetype 2.5.5 2 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
  13. intel-openmp 2019.4 243 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
  14. ipython 7.10.1 <pip>
  15. ipython-genutils 0.2.0 <pip>
  16. jbig 2.1 0 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
  17. jedi 0.15.1 <pip>
  18. jpeg 9b 0 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
  19. libffi 3.2.1 1 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
  20. libgcc-ng 9.1.0 hdf63c60_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
  21. libgfortran-ng 7.3.0 hdf63c60_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
  22. libpng 1.6.30 1 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
  23. libstdcxx-ng 9.1.0 hdf63c60_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
  24. libtiff 4.0.6 3 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
  25. mkl 2019.4 243 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
  26. mkl-service 2.3.0 py36he904b0f_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
  27. mkl_fft 1.0.15 py36ha843d7b_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
  28. mkl_random 1.1.0 py36hd6b4f25_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
  29. ninja 1.7.2 0 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
  30. numpy 1.17.4 py36hc1035e2_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
  31. numpy-base 1.17.4 py36hde5b4d6_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
  32. olefile 0.44 py36_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
  33. openssl 1.0.2l 0 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
  34. parso 0.5.1 <pip>
  35. pexpect 4.7.0 <pip>
  36. pickleshare 0.7.5 <pip>
  37. pillow 4.2.1 py36_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
  38. pip 9.0.1 py36_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  39. prompt-toolkit 3.0.2 <pip>
  40. ptyprocess 0.6.0 <pip>
  41. pycparser 2.18 py36_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
  42. Pygments 2.5.2 <pip>
  43. python 3.6.2 0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  44. pytorch 1.3.1 py3.6_cuda10.0.130_cudnn7.6.3_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch
  45. readline 6.2 2 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  46. setuptools 36.4.0 py36_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  47. six 1.10.0 py36_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/free
  48. sqlite 3.13.0 0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  49. tk 8.5.18 0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  50. traitlets 4.3.3 <pip>
  51. wcwidth 0.1.7 <pip>
  52. wheel 0.29.0 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  53. xz 5.2.3 0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  54. zlib 1.2.11 0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free

之后运行pytorch版的yolo3之后,报错:

python detect.py 
Traceback (most recent call last):
  File "detect.py", line 5, in <module>
    from utils.datasets import *
  File "/home/wosai/2020/PyTorch-YOLOv3/utils/datasets.py", line 12, in <module>
    import torchvision.transforms as transforms
  File "/home/wosai/anaconda3/envs/pytorch/lib/python3.6/site-packages/torchvision/__init__.py", line 1, in <module>
    from torchvision import models
  File "/home/wosai/anaconda3/envs/pytorch/lib/python3.6/site-packages/torchvision/models/__init__.py", line 11, in <module>
    from . import detection
  File "/home/wosai/anaconda3/envs/pytorch/lib/python3.6/site-packages/torchvision/models/detection/__init__.py", line 1, in <module>
    from .faster_rcnn import *
  File "/home/wosai/anaconda3/envs/pytorch/lib/python3.6/site-packages/torchvision/models/detection/faster_rcnn.py", line 7, in <module>
    from torchvision.ops import misc as misc_nn_ops
  File "/home/wosai/anaconda3/envs/pytorch/lib/python3.6/site-packages/torchvision/ops/__init__.py", line 1, in <module>
    from .boxes import nms, box_iou
  File "/home/wosai/anaconda3/envs/pytorch/lib/python3.6/site-packages/torchvision/ops/boxes.py", line 2, in <module>
    from torchvision import _C
ImportError: libcudart.so.9.0: cannot open shared object file: No such file or directory

竟然提示要cuda9,我明明我装了cuda10,测试了cuda是可用的,后来想想可能是torchvision版本的原因,因为我装的是torchvision0.3

于是pip install --upgrade torchvision

升级到了最新版本的0.4.2

再测试,成功!所以我在想是不是torch0.3要和cuda9对应,torchvision要和cuda10对应

ubuntu18对cuda10支持的比较好

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/351170
推荐阅读
相关标签
  

闽ICP备14008679号