Linux快速搭建tensorflow-gpu 1.15.0环境&Keras

Linux快速搭建tensorflow-gpu 1.15.0环境&Keras

========================

conda create -n tf115 -c conda-forge tensorflow-gpu=1.15

conda install keras==2.3.1

 

激活虚拟环境tf115 之后做以下操作:

 conda install -n tf115 ipykernel ### 必须
# pip install ipykernel ipython ### 必须
# python -m ipykernel install --user --name tf115 --display-name "tf115"   ### 必须

配置notebook之后

conda activate tf115

配置远程使用

()# nohup /home/software/anaconda3/bin/jupyter notebook --allow-root --notebook-dir='/data/r/' --ip 0.0.0.0 >> /home/software/anaconda3/bin/jupyter.log 2>&1

========================
 
1.创建虚拟环境:
conda create -n tf python=3.7
提醒:python3.8暂不支持tensorflow-gpu 1.15版本,请使用python3.6 ,3.7版本

2.显示自己创建的虚拟环境
conda env list

3.进入创建虚拟环境
source activate tf

4.安装指定 版本的TensorFlow
ps:若为tensorflow1.x版本则执行:
pip3 install tensorflow-gpu==1.15.0

ps:若为tensorflow2.x版本则执行:
pip3 install tensorflow-gpu==2.1.0

5.安装的包(务必执行)
ps:若为tensorflow1.x版本则执行:
conda install cudatoolkit=10.0 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64/
conda install cudnn=7.3.1 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64/

ps:若为tensorflow2.x版本则执行:
conda install cudatoolkit=10.1 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64/
conda install cudnn=7.6.5 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64/
 小技巧:若安装其他版本,先查看Tensorflow-gpu对应支持的cuda版本(官网),然后进入清华镜像网站,搜索cudnn,然后找到对应的cuda版本

6.验证是否安装成功
先输入python进入交互式界面,然后用如下命令验证是否gpu版本启用
import tensorflow as tf
tf.test.is_gpu_available()
若最后显示True,安装成功!

7.安装Keras(可选)
Keras需要在TensorFlow之上才能运行,所以要先安装Tensorflow;安装完Tensorflow后,输入以下命令安装Keras:
pip install keras==2.3.1 -i https://pypi.tuna.tsinghua.edu.cn/simple

链接:https://blog.csdn.net/weixin_43325818/article/details/110673189

posted @ 2023-02-02 22:41  emanlee  阅读(148)  评论(0编辑  收藏  举报