Ubuntu18.04安装TensorFlow

最近看代码,用到了TensorFlow,发现服务器里没有装,这里记录一下安装过程,方便以后查阅。

Ubuntu18.04安装TensorFlow

  • TensorFlow安装
  • 参考资料

TensorFlow安装

nvcc -V
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
cat /usr/local/cuda/include/cudnn_version.h | grep CUDNN_MAJOR -A 2

Ubuntu18.04安装TensorFlow_第1张图片

创建一个虚拟环境:

conda create -n tensorflow_env python==3.7

Ubuntu18.04安装TensorFlow_第2张图片

启动虚拟环境:

conda activate tensorflow_env

在虚拟环境中安装:

pip3 install --upgrade tensorflow

在这里插入图片描述

Ubuntu18.04安装TensorFlow_第3张图片

安装完成测试一下:

import tensorflow as tf

print('GPU', tf.test.is_gpu_available())

a = tf.constant(2.)
b = tf.constant(4.)

print(a * b)

输出如下信息:

在这里插入图片描述

参考资料

使用 pip 安装 TensorFlow

你可能感兴趣的:(Ubuntu,tensorflow,python,深度学习)