Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I use a tensorflow base image in the Dockerfile template? Is it possible? #1837

Open
5 tasks
prateeumich opened this issue Apr 11, 2024 · 3 comments
Open
5 tasks

Comments

@prateeumich
Copy link

prateeumich commented Apr 11, 2024

My actions before raising this issue

Why do you need this?

Who is this for?

What company is this for? Are you listed in the ADOPTERS.md file?

Expected Behaviour

Current Behaviour

I am trying to install tensorflow inside the docker container, is it possible to use a tensorflow base image or no? I can see we are only using alpine linux as the base image

Are you a GitHub Sponsor (Yes/No?)

NO
Check at: https://github.com/sponsors/openfaas

  • Yes
  • No

List All Possible Solutions and Workarounds

Which Solution Do You Recommend?

Steps to Reproduce (for bugs)

Context

Your Environment

  • FaaS-CLI version ( Full output from: faas-cli version ):
    version: 0.16.23

  • Docker version docker version (e.g. Docker 17.0.05 ):
    Docker version 26.0.0

  • Are you using OpenFaaS on Kubernetes or faasd?
    Yes using it on Minikube

  • Operating System and version (e.g. Linux, Windows, MacOS):
    Linux Ubuntu 22.0.4

  • Code example or link to GitHub repo or gist to reproduce problem:

  • Other diagnostic information / logs from troubleshooting guide

@alexellis
Copy link
Member

Hi @prateeumich of course, you can do whatever you want in a Dockerfile.

Can you share what do you have so far?

What programming language are you trying to use? Python?

@prateeumich
Copy link
Author

this is my dockerfile

**FROM ghcr.io/openfaas/classic-watchdog:0.2.3 as watchdog

FROM tensorflow/tensorflow:latest-gpu

RUN mkdir -p /home/app

COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
RUN chmod +x /usr/bin/fwatchdog

Add non root user

#RUN addgroup -S app && adduser app -S -G app

Add non root user

RUN groupadd -r app && useradd -r -g app app

RUN chown app /home/app
COPY program.py .

WORKDIR /home/app

USER app

Populate example here - i.e. "cat", "sha512sum" or "node index.js"

ENV fprocess="cat"

Set to true to see request in function logs

ENV write_debug="false"

EXPOSE 8080

HEALTHCHECK --interval=3s CMD [ -e /tmp/.lock ] || exit 1

CMD ["fwatchdog"]**

I have written a matmul program using tensorflow and python

import tensorflow as tf

# Check if GPU is available
if tf.test.is_gpu_available():
    print("GPU is available")
else:
    print("GPU is NOT available")

# Define a simple TensorFlow computation graph
a = tf.constant(3.0)
b = tf.constant(4.0)
c = tf.add(a, b)

# Create a TensorFlow session
with tf.Session() as sess:
    # Execute the computation graph
    result = sess.run(c)
    print("Result:", result)

I was able to up the function but when I was invoking the function there was no output in the command line

Faas

@prateeumich
Copy link
Author

Also, when is the copy step correct or is it why it isn't running the program?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants