[关闭]
@yangwenbo 2023-02-10T17:29:25.000000Z 字数 2059 阅读 282

清华大学-FIB实验室

安装深度学习框架 pytorch、tensorflow

tensorflow可以直接pip装,pytorch请务必从这里装https://download.pytorch.org/whl/torch_stable.html下载对应cuda版本编译的安装包,放到服务器里pip install xxxx.whl

1、安装tensorflow

  1. #安装依赖包
  2. (python-3.7) root@7a927d2dc743:~# pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --user pytest-cov==2.0 pytest-filter-subpackage==0.1
  1. #安装指定版本的tensorflow
  2. (python-3.7) root@7a927d2dc743:~# pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow==2.3.0
  1. #验证tensorflow是否安装成功
  2. (python-3.7) root@7a927d2dc743:~# pip show tensorflow
  3. Name: tensorflow
  4. Version: 2.3.0
  5. Summary: TensorFlow is an open source machine learning framework for everyone.
  6. Home-page: https://www.tensorflow.org/
  7. Author: Google Inc.
  8. Author-email: packages@tensorflow.org
  9. License: Apache 2.0
  10. Location: /usr/local/anaconda3/envs/python-3.7/lib/python3.7/site-packages
  11. Requires: absl-py, astunparse, gast, google-pasta, grpcio, h5py, keras-preprocessing, numpy, opt-einsum, protobuf, scipy, six, tensorboard, tensorflow-estimator, termcolor, wheel, wrapt
  12. Required-by:

2、安装pytorch

  1. #下载对应cuda版本编译的安装包
  2. (python-3.7) root@7a927d2dc743:~# wget -P ./ https://download.pytorch.org/whl/cu102/torch-1.6.0-cp37-cp37m-linux_x86_64.whl
  3. (python-3.7) root@7a927d2dc743:~# ll -d torch-1.6.0-cp37-cp37m-linux_x86_64.whl
  4. -rw-r--r-- 1 root root 748807916 Jul 28 2020 torch-1.6.0-cp37-cp37m-linux_x86_64.whl
  1. #安装下载好的安装包
  2. (python-3.7) root@7a927d2dc743:~# pip install torch-1.6.0-cp37-cp37m-linux_x86_64.whl
  3. Processing ./torch-1.6.0-cp37-cp37m-linux_x86_64.whl
  4. Requirement already satisfied: numpy in /usr/local/anaconda3/lib/python3.7/site-packages (from torch==1.6.0) (1.21.5)
  5. Requirement already satisfied: future in /usr/local/anaconda3/lib/python3.7/site-packages (from torch==1.6.0) (0.18.2)
  6. Installing collected packages: torch
  7. Successfully installed torch-1.6.0
  1. #验证pytorch是否安装成功,这里可以写一个小脚本验证下,如没有报错就是安装成功了
  2. (python-3.7) root@7a927d2dc743:~# vim pytorch.py
  3. (python-3.7) root@7a927d2dc743:~# cat pytorch.py
  4. from __future__ import print_function
  5. import torch
  6. x = torch.rand(5, 3)
  7. print(x)
  8. (python-3.7) root@7a927d2dc743:~# python3.7 pytorch.py
  9. tensor([[0.5560, 0.5296, 0.1896],
  10. [0.5847, 0.7915, 0.7916],
  11. [0.9128, 0.2412, 0.1217],
  12. [0.7183, 0.0343, 0.9444],
  13. [0.3063, 0.0969, 0.9200]])
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注