Skip to content

Instantly share code, notes, and snippets.

@hanneshapke
Last active February 12, 2023 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hanneshapke/9a87b932a02c7838b6ba68ded951811a to your computer and use it in GitHub Desktop.
Save hanneshapke/9a87b932a02c7838b6ba68ded951811a to your computer and use it in GitHub Desktop.
TensorBoard Profiler + TensorFlow Serving
#!/bin/bash
TENSORFLOW_SERVING_VERSION=2.11.0
TENSORFLOW_SERVING_HOSTNAME=serving
TENSORFLOW_SERVING_MODEL_NAME=test_model
INTRA_OP_PARALLELISM=2
INTER_OP_PARALLELISM=2
TENSORBOARD_LOGDIR="/tmp/tensorboard"
DOCKER_PROFILER_TAG=tensorboard_profiler:latest
MKDIR_CMD="mkdir -p ${TENSORBOARD_LOGDIR}"
echo $MKDIR_CMD
eval $MKDIR_CMD
echo """FROM tensorflow/tensorflow:${TENSORFLOW_SERVING_VERSION}
RUN pip install -U tensorboard-plugin-profile
ENTRYPOINT [\"/usr/bin/python3\", \"-m\", \"tensorboard.main\", \"--logdir\", \"/tmp/tensorboard\", \"--bind_all\"]
""">Dockerfile_tfprofile
docker build -t ${DOCKER_PROFILER_TAG} -f Dockerfile_tfprofile .
echo """version: '3.3'
services:
${TENSORFLOW_SERVING_HOSTNAME}:
image: tensorflow/serving:${TENSORFLOW_SERVING_VERSION}
ports:
- '8500:8500'
- '8501:8501'
environment:
- MODEL_NAME=${TENSORFLOW_SERVING_MODEL_NAME}
hostname: '${TENSORFLOW_SERVING_HOSTNAME}'
volumes:
- '/models/${TENSORFLOW_SERVING_MODEL_NAME}:/models/${TENSORFLOW_SERVING_MODEL_NAME}'
- '${TENSORBOARD_LOGDIR}:/tmp/tensorboard'
command:
- '--xla_cpu_compilation_enabled'
- '--tensorflow_intra_op_parallelism=${INTRA_OP_PARALLELISM}'
- '--tensorflow_inter_op_parallelism=${INTER_OP_PARALLELISM}'
profiler:
image: ${DOCKER_PROFILER_TAG}
ports:
- '6006:6006'
volumes:
- '${TENSORBOARD_LOGDIR}:/tmp/tensorboard'
""">docker-compose.yaml
docker-compose up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment