tensorflow有一种简单的使用方法,就是直接运行官方提供的docker镜像,该镜像安装好了tensorflow运行环境,直接食用即可:
1、没有docker环境的,最简单的docker环境安装见这里。
2、拉取最新tensorflow docker镜像
sudo docker pull tensorflow/tensorflow:latest
3、通过docker镜像启动jupyter服务
sudo docker run -it -p 8888:8888 tensorflow/tensorflow:latest-jupyter
输出如下:
[xxx@fedora ~]$ docker run -it -p 8888:8888 tensorflow/tensorflow:latest-jupyter
[I 02:53:45.331 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
jupyter_http_over_ws extension initialized. Listening on /http_over_websocket
[I 02:53:45.591 NotebookApp] Serving notebooks from local directory: /tf
[I 02:53:45.591 NotebookApp] Jupyter Notebook 6.3.0 is running at:
[I 02:53:45.591 NotebookApp] http://5da7cc9a6978:8888/?token=4865b5c6fbe5ffcf5ea6a2c645f0a6dd246d55ac1f57b0fd
[I 02:53:45.591 NotebookApp] or http://127.0.0.1:8888/?token=4865b5c6fbe5ffcf5ea6a2c645f0a6dd246d55ac1f57b0fd
[I 02:53:45.591 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 02:53:45.598 NotebookApp]
To access the notebook, open this file in a browser:
file:///root/.local/share/jupyter/runtime/nbserver-1-open.html
Or copy and paste one of these URLs:
http://5da7cc9a6978:8888/?token=4865b5c6fbe5ffcf5ea6a2c645f0a6dd246d55ac1f57b0fd
or http://127.0.0.1:8888/?token=4865b5c6fbe5ffcf5ea6a2c645f0a6dd246d55ac1f57b0fd
4、通过浏览器登陆jupyter
上一步骤开启jupyter服务时,最后提供了登录地址,通过浏览器访问即可。
5、使用指定版本的tensorflow
latest是最新的版本,如果需要使用特定版本的tensorflow,就需要对应版本的镜像。tensorflow的镜像仓库地址如下,可以搜索查找对应的tag版本:
https://hub.docker.com/r/tensorflow/tensorflow/tags?page=1&ordering=last_updated
(End)