質問編集履歴
5
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -19,8 +19,9 @@
|
|
19
19
|
feed_dictを使うと停止してしまうみたいなのですが、どうすれば改善できると思いますか?
|
20
20
|
ご意見よろしくお願い致します。
|
21
21
|
必要があればコードやスペックなども記述しますので、宜しくお願い致します。
|
22
|
+
以下、nvidia-smiを実行。
|
23
|
+
GPU-Util = 0%なのが気がかりです。
|
22
24
|
|
23
|
-
|
24
25
|
```
|
25
26
|
+-----------------------------------------------------------------------------+
|
26
27
|
| NVIDIA-SMI 384.111 Driver Version: 384.111 |
|
4
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -39,4 +39,109 @@
|
|
39
39
|
| 0 7449 C python 11634MiB |
|
40
40
|
+-----------------------------------------------------------------------------+
|
41
41
|
|
42
|
+
```
|
43
|
+
|
44
|
+
以下、上手く実行された例
|
45
|
+
```ここに言語を入力
|
46
|
+
# -*- coding: utf-8 -*-
|
47
|
+
|
48
|
+
import tensorflow as tf
|
49
|
+
import numpy as np
|
50
|
+
|
51
|
+
# Create 100 phony x, y data points in NumPy, y = x * 0.1 + 0.3
|
52
|
+
x_data = np.random.rand(1000,100).astype(np.float32)
|
53
|
+
y_data = x_data * 0.1 + 0.3
|
54
|
+
print(x_data)
|
55
|
+
|
56
|
+
X = tf.placeholder(dtype = tf.float32, shape = [None, x_data.shape[1]])
|
57
|
+
Y = tf.placeholder(dtype = tf.float32, shape = [None, y_data.shape[1]])
|
58
|
+
# Try to find values for W and b that compute y_data = W * x_data + b
|
59
|
+
# (We know that W should be 0.1 and b 0.3, but TensorFlow will
|
60
|
+
# figure that out for us.)
|
61
|
+
W = tf.Variable(tf.random_uniform([100,100], -1.0, 1.0))
|
62
|
+
b = tf.Variable(tf.zeros([1]))
|
63
|
+
|
64
|
+
######相違点#######
|
65
|
+
y = W * X + b
|
66
|
+
#y=tf.matmul(W,X)+b
|
67
|
+
|
68
|
+
# Minimize the mean squared errors.
|
69
|
+
loss = tf.reduce_mean(tf.square(y -Y))
|
70
|
+
optimizer = tf.train.GradientDescentOptimizer(0.5)
|
71
|
+
train = optimizer.minimize(loss)
|
72
|
+
|
73
|
+
# Before starting, initialize the variables. We will 'run' this first.
|
74
|
+
init = tf.global_variables_initializer()
|
75
|
+
|
76
|
+
# Launch the graph.
|
77
|
+
sess = tf.Session()
|
78
|
+
sess.run(init)
|
79
|
+
#print(x_data)
|
80
|
+
#print(y_data)
|
81
|
+
|
82
|
+
# Fit the line.
|
83
|
+
for step in range(201):
|
84
|
+
#sess.run(train)
|
85
|
+
sess.run(train,feed_dict={X:x_data[0:100],Y:y_data[0:100]})
|
86
|
+
if step % 20 == 0:
|
87
|
+
print(step, sess.run(W), sess.run(b))
|
88
|
+
|
89
|
+
# Learns best fit is W: [0.1], b: [0.3]
|
90
|
+
|
91
|
+
# Close the Session when we're done.
|
92
|
+
sess.close()
|
93
|
+
|
94
|
+
```
|
95
|
+
|
96
|
+
以下、上手くいかずフリーズした例
|
97
|
+
```ここに言語を入力
|
98
|
+
# -*- coding: utf-8 -*-
|
99
|
+
|
100
|
+
import tensorflow as tf
|
101
|
+
import numpy as np
|
102
|
+
|
103
|
+
# Create 100 phony x, y data points in NumPy, y = x * 0.1 + 0.3
|
104
|
+
x_data = np.random.rand(1000,100).astype(np.float32)
|
105
|
+
y_data = x_data * 0.1 + 0.3
|
106
|
+
print(x_data)
|
107
|
+
|
108
|
+
X = tf.placeholder(dtype = tf.float32, shape = [None, x_data.shape[1]])
|
109
|
+
Y = tf.placeholder(dtype = tf.float32, shape = [None, y_data.shape[1]])
|
110
|
+
# Try to find values for W and b that compute y_data = W * x_data + b
|
111
|
+
# (We know that W should be 0.1 and b 0.3, but TensorFlow will
|
112
|
+
# figure that out for us.)
|
113
|
+
W = tf.Variable(tf.random_uniform([100,100], -1.0, 1.0))
|
114
|
+
b = tf.Variable(tf.zeros([1]))
|
115
|
+
|
116
|
+
######相違点#######
|
117
|
+
#y = W * X + b
|
118
|
+
y=tf.matmul(W,X)+b
|
119
|
+
|
120
|
+
|
121
|
+
# Minimize the mean squared errors.
|
122
|
+
loss = tf.reduce_mean(tf.square(y -Y))
|
123
|
+
optimizer = tf.train.GradientDescentOptimizer(0.5)
|
124
|
+
train = optimizer.minimize(loss)
|
125
|
+
|
126
|
+
# Before starting, initialize the variables. We will 'run' this first.
|
127
|
+
init = tf.global_variables_initializer()
|
128
|
+
|
129
|
+
# Launch the graph.
|
130
|
+
sess = tf.Session()
|
131
|
+
sess.run(init)
|
132
|
+
#print(x_data)
|
133
|
+
#print(y_data)
|
134
|
+
|
135
|
+
# Fit the line.
|
136
|
+
for step in range(201):
|
137
|
+
#sess.run(train)
|
138
|
+
sess.run(train,feed_dict={X:x_data[0:100],Y:y_data[0:100]})
|
139
|
+
if step % 20 == 0:
|
140
|
+
print(step, sess.run(W), sess.run(b))
|
141
|
+
|
142
|
+
# Learns best fit is W: [0.1], b: [0.3]
|
143
|
+
|
144
|
+
# Close the Session when we're done.
|
145
|
+
sess.close()
|
146
|
+
|
42
147
|
```
|
3
nvidia-smiの追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -18,4 +18,25 @@
|
|
18
18
|
|
19
19
|
feed_dictを使うと停止してしまうみたいなのですが、どうすれば改善できると思いますか?
|
20
20
|
ご意見よろしくお願い致します。
|
21
|
-
必要があればコードやスペックなども記述しますので、宜しくお願い致します。
|
21
|
+
必要があればコードやスペックなども記述しますので、宜しくお願い致します。
|
22
|
+
|
23
|
+
|
24
|
+
```
|
25
|
+
+-----------------------------------------------------------------------------+
|
26
|
+
| NVIDIA-SMI 384.111 Driver Version: 384.111 |
|
27
|
+
|-------------------------------+----------------------+----------------------+
|
28
|
+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
|
29
|
+
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|
30
|
+
|===============================+======================+======================|
|
31
|
+
| 0 GeForce GTX TIT... Off | 00000000:02:00.0 Off | N/A |
|
32
|
+
| 22% 48C P2 67W / 250W | 11645MiB / 12205MiB | 0% Default |
|
33
|
+
+-------------------------------+----------------------+----------------------+
|
34
|
+
|
35
|
+
+-----------------------------------------------------------------------------+
|
36
|
+
| Processes: GPU Memory |
|
37
|
+
| GPU PID Type Process name Usage |
|
38
|
+
|=============================================================================|
|
39
|
+
| 0 7449 C python 11634MiB |
|
40
|
+
+-----------------------------------------------------------------------------+
|
41
|
+
|
42
|
+
```
|
2
誤字
title
CHANGED
File without changes
|
body
CHANGED
@@ -16,4 +16,6 @@
|
|
16
16
|
ちなみに、ctr+Cを押しても停止できません。
|
17
17
|
nvidia-smiでGPUの使用状況を確認するとGPUはしっかり使われています。
|
18
18
|
|
19
|
-
feed_dictを使うと停止してしまうみたいなのですが、どうすれば改善できると思いますか?
|
19
|
+
feed_dictを使うと停止してしまうみたいなのですが、どうすれば改善できると思いますか?
|
20
|
+
ご意見よろしくお願い致します。
|
21
|
+
必要があればコードやスペックなども記述しますので、宜しくお願い致します。
|
1
誤字
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
### 前提・実現したいこと
|
2
2
|
|
3
|
-
ここに質問の内容を詳しく書いてください。
|
4
3
|
tensorflowを使ってGPUで学習をしようとしています。
|
5
4
|
同じプログラムをCPUで実行すると問題なく実行できますが、
|
6
5
|
GPUを使うと以下のsess.run(train)でフリーズしてしまいます。
|