-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscratchpad.py
More file actions
36 lines (28 loc) · 803 Bytes
/
scratchpad.py
File metadata and controls
36 lines (28 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import tensorflow as tf
from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())
hello=tf.constant('Hello, TensorFlow!')
sess=tf.Session()
print(sess.run(hello))
import os
os.environ['CUDA_VISIBLE_DEVICES']='-1'
import tensorflow as tf
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.Session(config=config)
import tensorflow as tf
from keras import backend as K
num_cores = 4
CPU=True
GPU=False
if GPU:
num_GPU = 1
num_CPU = 1
if CPU:
num_CPU = 1
num_GPU = 0
config = tf.ConfigProto(intra_op_parallelism_threads=num_cores,\
inter_op_parallelism_threads=num_cores, allow_soft_placement=True,\
device_count = {'CPU' : num_CPU, 'GPU' : num_GPU})
session = tf.Session(config=config)
K.set_session(session)