1. tensor2tensor运行在GPU上面的简单总结
- 首先测试tensorflow的简单程序能否运行在GPU上面,执行下面的代码
import tensorflow as tf
with tf.device('/device:GPU:0'):
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
c = tf.matmul(a, b)
sess = tf.Session()
sess.run(c)
2. 使用conda安装tensor2tensor
conda create --name PY368 python==3.6.8
conda activate PY368
conda install pip
pip install tf-nightly-gpu
pip install tensor2tensor[tensorflow_gpu]
cat /usr/local/cuda/version.txt
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
conda search cuda
conda install cudatoolkit==10.0.130
watch -n1 nvidia-smi
sudo echo "GatewayPorts yes" >> /etc/ssh/sshd_config
systemctl restart sshd
ssh -qTfNn -R '[::]:10036:localhost:6006' [email protected](公网ip)
注意事项
- 目前tensorflow并不支持cuda10.1(20190919),具体请注意官网的声明
- 可以使用conda安装cuda环境,这样可以做到cuda环境的隔离