Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python
import tensorflow as tf
import numpy as np
from tensorflow import keras
print(tf.__version__)
print(tf.keras.__version__)
inputs = []
inputs.append(keras.Input(shape=(1,), name='x_float', dtype='float32'))
@thuningxu
thuningxu / Dockerfile.cpu
Created April 12, 2019 20:55
Horovod docker for CPU only
#FROM nvidia/cuda:9.0-devel-ubuntu16.04
FROM ubuntu:16.04
# TensorFlow version is tightly coupled to CUDA and cuDNN so it should be selected carefully
ENV TENSORFLOW_VERSION=1.12.0
ENV PYTORCH_VERSION=1.0.0
# Python 2.7 or 3.5 is supported by Ubuntu Xenial out of the box
ARG python=3.5
ENV PYTHON_VERSION=${python}
import horovod.tensorflow as hvd
import tensorflow as tf
import time
config = tf.ConfigProto()
tf.enable_eager_execution(config=config)
hvd.init()
with tf.device("/cpu:0"):
tf.set_random_seed(1234)