docker環境下安裝tensorflow
下載tensorflow 映象並執行
[root@Ieat1 ~]# docker run -d --name tensorflow -it -p 8888:8888 tensorflow/tensorflow
ff716bcb8642e258eb7007f3f0c6756a82998d2844df8b374df85c9faf1b0629
通過觀察發現新建的notebook都在容器的/notebooks目錄下,為了使notebook不丟失,我們可以把它放在宿主機的目錄上,比如/data/tensorflow/notebooks,啟動時指定卷
docker run -d --name tensorflow -v /data/tensorflow/notebooks:/notebooks -it -p 8888:8888 tensorflow/tensorflow
檢視docker日誌,發現提示我們訪問地址 http://127.0.0.1:8888/?token=061bdda51d27eaab82049d1eda42bd63381a4c4d33eaee67
[root@Ieat1 ~]# docker logs -f tensorflow
[I 06:11:01.349 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
[W 06:11:01.372 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[I 06:11:01.383 NotebookApp] Serving notebooks from local directory: /notebooks
[I 06:11:01.383 NotebookApp] The Jupyter Notebook is running at:
[I 06:11:01.383 NotebookApp] http://(ff716bcb8642 or 127.0.0.1):8888/?token=061bdda51d27eaab82049d1eda42bd63381a4c4d33eaee67
[I 06:11:01.383 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 06:11:01.383 NotebookApp]
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://(ff716bcb8642 or 127.0.0.1):8888/?token=061bdda51d27eaab82049d1eda42bd63381a4c4d33eaee67
訪問後看到 jupyter介面,我們可以線上編輯程式碼
jupyter介紹參考 https://www.jianshu.com/p/91365f343585
新建notebook
輸入示例程式碼點選Run執行
import tensorflow as tf
import numpy as np
# 使用 NumPy 生成假資料(phony data), 總共 100 個點.
x_data = np.float32(np.random.rand(2, 100)) # 隨機輸入
y_data = np.dot([0.100, 0.200], x_data) + 0.300
# 構造一個線性模型
#
b = tf.Variable(tf.zeros([1]))
W = tf.Variable(tf.random_uniform([1, 2], -1.0, 1.0))
y = tf.matmul(W, x_data) + b
# 最小化方差
loss = tf.reduce_mean(tf.square(y - y_data))
optimizer = tf.train.GradientDescentOptimizer(0.5)
train = optimizer.minimize(loss)
# 初始化變數
init = tf.initialize_all_variables()
# 啟動圖 (graph)
sess = tf.Session()
sess.run(init)
# 擬合平面
for step in range(0, 201):
sess.run(train)
if step % 20 == 0:
print step, sess.run(W), sess.run(b)
示例程式碼地址 http://www.tensorfly.cn/tfdoc/get_started/introduction.html
看到執行成功
相關文章
- Docker 下安裝配置 lnmp 環境DockerLNMP
- Windows環境下Python3.7安裝TensorflowWindowsPython
- Linux 下使用 Docker 安裝lnmp環境LinuxDockerLNMP
- (轉)Windows下安裝Docker, GitBash環境配置WindowsDockerGit
- Linux環境下透過docker安裝mysqlLinuxDockerMySql
- Ubuntu 22.04 安裝Docker環境UbuntuDocker
- docker安裝多環境ApolloDocker
- Windows 環境下 Python 環境安裝WindowsPython
- 常用環境部署—Docker安裝RocketMQ教程!DockerMQ
- ros2 jazzy docker環境安裝ROSDocker
- 無網環境安裝docker之--rpmDocker
- Linux下安裝Go環境LinuxGo
- linux環境下redis安裝LinuxRedis
- Windows環境下安裝LinuxWindowsLinux
- Windows環境下安裝NexusWindows
- Windows 環境下安裝 RedisWindowsRedis
- Windows 環境下安裝 LaravelWindowsLaravel
- Mac環境下安裝PodMac
- Linux下Java環境安裝LinuxJava
- Windows環境下安裝RabbitMQWindowsMQ
- kali環境下安裝dvwa
- Linux環境下安裝NginxLinuxNginx
- Ubuntu下使用conda在虛擬環境中安裝CUDA、CUDNN及TensorflowUbuntuDNN
- Docker環境下編譯安裝PHP7.1.4 Nginx1.12.0Docker編譯PHPNginx
- docker安裝tensorflow-gpuDockerGPU
- linux或者CentOS環境下安裝.NET Core環境LinuxCentOS
- centos 7.2 64位 docker安裝lamp環境CentOSDockerLAMP
- 用docker安裝laravel的開發環境DockerLaravel開發環境
- ubuntu環境下安裝perf工具Ubuntu
- Linux環境下nginx安裝配置LinuxNginx
- 在Ubuntu環境下安裝eclipseUbuntuEclipse
- Mac環境下安裝配置RedisMacRedis
- Linux環境下ApacheActiveMQ基本安裝LinuxApacheMQ
- docker 筆記1--在virtualBox + vagrant 建立的虛擬環境下安裝dockerDocker筆記
- Docker 驗證 Centos7.2 離線安裝 Docker 環境DockerCentOS
- (傻瓜版)Tensorflow-GPU安裝及TensorflowObjectionDetectionAPI環境搭建GPUObjectAPI
- 使用docker搭建環境:安裝tomcat、部署war包DockerTomcat
- docker 安裝 Laravel 環境 (nginx mariadb PHP7.2)DockerLaravelNginxPHP