重装系统以后,安装深度学习环境还真麻烦,我这里对装tensorflow python3的环境进行整理:

sudo apt-get install python3-pip
sudo pip3 install tensorflow-gpu
sudo pip3 install opencv-python


我们还可能用到jupyter notebook,安装命令如下:

sudo pip3 install jupyter


python下查看opencv版本:

python
import cv2
cv2.__version__


命令行输入:

python3

然后运行tensorflow安装成功测试代码:

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print( sess.run(hello))
a = tf.constant(10)
b = tf.constant(32)
print(sess.run(a+b))

会有打印输出,例如,我在TX2上安装成功后,输出为:

ubuntu@tegra-ubuntu:~$ python3
Python 3.5.2 (default, Sep 14 2017, 22:51:06)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
2017-11-21 06:22:38.820962: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:857] ARM64 does not support NUMA - returning NUMA node zero
2017-11-21 06:22:38.821085: I tensorflow/core/common_runtime/gpu/gpu_device.cc:955] Found device 0 with properties:
name: NVIDIA Tegra X2
major: 6 minor: 2 memoryClockRate (GHz) 1.3005
pciBusID 0000:00:00.0
Total memory: 7.67GiB
Free memory: 5.34GiB
2017-11-21 06:22:38.821134: I tensorflow/core/common_runtime/gpu/gpu_device.cc:976] DMA: 0
2017-11-21 06:22:38.821159: I tensorflow/core/common_runtime/gpu/gpu_device.cc:986] 0: Y
2017-11-21 06:22:38.821195: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1045] Creating TensorFlow device (/gpu:0) -> (device: 0, name: NVIDIA Tegra X2, pci bus id: 0000:00:00.0)
>>> print(tf.Session())
2017-11-21 06:23:00.939320: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1045] Creating TensorFlow device (/gpu:0) -> (device: 0, name: NVIDIA Tegra X2, pci bus id: 0000:00:00.0)
<tensorflow.python.client.session.Session object at 0x7f97f03ef0>
>>> a=tf.constant(10)
>>> b=tf.constant(32)
>>> print(sess.run(a+b))
42


会有你的显卡输出信息,我这里是tx2



参考文献


[1]. ubuntu16.04 python3安装opencv及tensorflow.