Ubuntu安装TensorFlow 1.15

文章目录

  • 创建虚拟环境
  • 安装TensorFlow1.15
  • 检查是否可用

创建虚拟环境

先创建一个conda虚拟环境,指定python版本为3.6 (TensorFlow版本大于1.14的话,最好都用python3.6)

conda create -n gnn-tf1 python=3.6

进入虚拟环境,查看python版本
在这里插入图片描述

安装TensorFlow1.15

TensorFlow1.15和CUDA10.0是匹配的,如果TensorFlow2.2及以上的话要用CUDA10.1。CUDA10.0的话最好就用TensorFlow1.15或者TensorFlow2.0.0。

使用阿里云安装TensorFlow1.15,清华镜像总是timeout失败了N遍

pip --default-timeout=100 install --upgrade -i https://mirrors.aliyun.com/pypi/simple tensorflow==1.15.0

下载速度和网速有关,快的时候1分钟不到,慢的话估计10分钟左右
Ubuntu安装TensorFlow 1.15_第1张图片
Ubuntu安装TensorFlow 1.15_第2张图片

到这里,说明tensorflow已经安装完了

检查是否可用

再安装一下jupyterlab和notebook

conda install jupyterlab notebook

安装完后打开jupyter notebook检查一下tensorflow是否能用

Ubuntu安装TensorFlow 1.15_第3张图片

可以看到cuda和gpu都可以用,到这里就安装成功了。注意,tensorflow默认使用编号为0的GPU,如果要用其他GPU最好制定一下,不然会报错。

import os
os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"] = "1,2"

你可能感兴趣的:(#,Ubuntu,#,图神经网络,tensorflow,深度学习,ubuntu,安装教程)