使用 Docker 运行 Tensorflow

前面写过一篇文档,如何在 CentOS 安装 GPU 驱动 ,这篇就来看看怎么利用 Docker 运行 Tensorflow 。

1. 检查当前 CPU 支持的 Tensorflow 版本

在不支持 AVX 指令的 CPU 上,运行 Tensorflow > 1.15 版本时,会报错,Illegal instruction (core dumped)。执行检测命令:

相关推荐

站点声明:本站部分内容转载自网络,作品版权归原作者及来源网站所有,任何内容转载、商业用途等均须联系原作者并注明来源。

相关侵权、举报、投诉及建议等,请发邮件至E-mail:service@mryunwei.com

回到顶部
1
2
3
cat /proc/cpuinfo | grep avx

flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx rdtscp lm constant_tsc rep_good nopl xtopology eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx smap xsaveopt arat
from tensorflow.python.client import device_lib
device_lib.list_local_devices()
mkdir ~/notebooks
docker run --name tf-gpu -d --runtime=nvidia --rm -it -v $(realpath ~/notebooks):/tf/notebooks -p 8881:8888 tensorflow/tensorflow:latest-gpu-jupyter
docker exec -it tf-gpu cat /root/.local/share/jupyter/runtime/nbserver-1-open.html

<!DOCTYPE html>
<p>
    This page should redirect you to Jupyter Notebook. If it doesn't,
    <a href="http://0.0.0.0:8888/tree?token={{token}}">click here to go to Jupyter</a>.
</p>

</body>
mkdir ~/notebooks
docker run --name tf-cpu -d --rm -it -v $(realpath ~/notebooks):/tf/notebooks -p 8882:8888 tensorflow/tensorflow:latest-jupyter
docker exec -it tf-cpu cat /root/.local/share/jupyter/runtime/nbserver-1-open.html

<!DOCTYPE html>
<p>
    This page should redirect you to Jupyter Notebook. If it doesn't,
    <a href="http://0.0.0.0:8888/tree?token={{token}}">click here to go to Jupyter</a>.
</p>

</body>