openfaas / faas

OpenFaaS - Serverless Functions Made Simple
https://www.openfaas.com
MIT License
24.75k stars 1.92k forks source link

Request for CUDA access #1805

Closed Abhishekghosh1998 closed 9 months ago

Abhishekghosh1998 commented 11 months ago

My actions before raising this issue

Why do you need this? I need it for my personal use.

Who is this for? I am Grad student.

Expected Behaviour

I have a use case that requires a container to interact with the base operating system for interprocess communication. I can achieve that using the --ipc=host option in the docker run command.

For example: docker run -it --ipc=host my_custom_image:latest

I have packaged the required code in a Dockerfile (for OpenFaas, using the Dockerfile template). The code works fine for basic functionality, but it fails when I need to communicate with the host os.

On a Kubernetes cluster, I tried to achieve the same functionality of using the hostIPC namespace as follows:

apiVersion: v1
kind: Pod
metadata:
  name: my-pod
spec:
  hostIPC: true
  restartPolicy: Never
  containers:
    - name: cuda-container
      image: my_custom_image:latest
...

I am not sure, but since OpenFaaS uses Dockerfile to build the image of the function to run, and then pushes it to the registry and then deploys it, I guess during the deployment or function triggering, it executes a command like docker run or Kubernetes pod creation.

I want to add that --ipc=host to this docker run command which spawns the container for the function. Or something equivalent to spec: hostIPC: true as in the pod description .yml file.

Can you help me with how this functionality can be achieved? Any specific field in the stack.yml file to deploy the function?

For example, I have the following stack yml file for a function named print-1: image

What field to add in the above yml file so that the deployment for pod in kubernetes shows spec: hostIPC: true: image

Current Behaviour

Are you a GitHub Sponsor (Yes/No?)

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

List All Possible Solutions and Workarounds

Which Solution Do You Recommend?

Steps to Reproduce (for bugs)

1. 2. 3. 4.

Context

## Your Environment
alexellis commented 9 months ago

Is host IPC actually needed? Are you trying to use a GPU?

Most people have used node scheduling constraints and that has worked for them. https://docs.openfaas.com/reference/profiles/#use-tolerations-and-affinity-to-separate-workloads

alexellis commented 9 months ago

/set title: Request for CUDA access

Abhishekghosh1998 commented 9 months ago

@alexellis Yes, I was trying to use the GPU with OpenFaaS. I tried to use the Kubernetes Webhook idea you gave me. I am not sure whether host IPC is required or not. However, the pointers which you gave, I shall look into it. Thanks for the same.

alexellis commented 9 months ago

If you want to use a GPU, I don't believe you need host IPC. I've never had someone say they needed it, and a number of people have used GPUs before.

Make sure docker-nvidia or containerd-nvidia is properly configured then use a scheduling constraint.