安装python、tensorflow、PyTorch、keras、Anaconda、open cv2

首先确定 CUDA 版本

CUDA 10.0

nvidia/cuda:10.0-runtime-ubuntu16.04

CUDA 9.0

nvidia/cuda:9.0-runtime-ubuntu16.04

然后安装必备依赖项

apt update

apt install -y wget


然后确定 python 版本

python 2

wget https://repo.anaconda.com/archive/Anaconda2-2019.10-Linux-x86_64.sh

bash Anaconda2-2019.10-Linux-x86_64.sh

一路回车+输入yes即可


PyTorch 2.7

wget https://repo.anaconda.com/archive/Anaconda2-2019.03-Linux-x86_64.sh

bash Anaconda2-2019.03-Linux-x86_64.sh

一路回车+输入yes即可


python 3

wget https://repo.anaconda.com/archive/Anaconda3-2019.10-Linux-x86_64.sh

bash Anaconda3-2019.10-Linux-x86_64.sh

一路回车+输入yes即可


python 3.5

wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-4.2.0-Linux-x86_64.sh

bash Anaconda3-4.2.0-Linux-x86_64.sh

一路回车+输入yes即可


python 3.6

wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.0.1-Linux-x86_64.sh

bash Anaconda3-5.0.1-Linux-x86_64.sh

一路回车+输入yes即可


Anaconda3.5.3.0+python3.7

wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.3.0-Linux-x86_64.sh

bash Anaconda3-5.3.0-Linux-x86_64.sh

一路回车+输入yes即可


其他版本

https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/


安装注意事项:

这里按回车,这里一直按空格,直到末尾

输入 yes,按回车,yes

安装成功后,退出 ssh,再次 ssh,输入 python,说明安装成功。


安装 Tensorflow GPU 版

安装tensorflow-GPU 1.7(其他版本类似)

pip install -U tensorflow-gpu==1.7

安装tensorflow-GPU 1.7 中国境内阿里源加速(其他版本类似)

pip install--upgrade pip

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow-gpu==1.7

安装 tensorflow 1.14 版本(其他版本类似)

pip install tensorflow-gpu==1.14

安装 keras 2.2.2 版本(其他版本类似)

pip install keras==2.2.2

测试,依次按行输入以下命令并回车

python

import tensorflow as tf

sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))

看到类似下图说明安装成功。


安装 keras

pip3 install keras

pip install keras

pip install keras ==指定版本

tensorflow 1.2对应的keras版本是2.0.6

安装 Pytorch GPU 版

pip install torch torchvision

测试

python

import torch

cudnn.is_available()

看到类似下图说明安装成功。

安装 Anaconda

Anaconda3-2019.10-Linux-x86_64.sh

wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2019.10-Linux-x86_64.sh

bash Anaconda3-2019.10-Linux-x86_64.sh

一路回车+输入yes即可

Anaconda3.5.0.1+python3.6

wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.0.1-Linux-x86_64.sh

bash Anaconda3-5.0.1-Linux-x86_64.sh

一路回车+输入yes即可

其他版本

https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/

安装open cv2 

pip install opencv-python

验证安装

python

import cv2

不行就

apt-get install python-opencv

如果报错 -bash: pip3: command not found

那就  /pip路径 install opencv-python 例如:

/opt/conda/bin/pip install opencv-python

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容