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

[MISC] Modify docker builds to make configurable base image #1935

Closed
2 tasks
Tracked by #1606
blythed opened this issue Apr 2, 2024 · 4 comments
Closed
2 tasks
Tracked by #1606

[MISC] Modify docker builds to make configurable base image #1935

blythed opened this issue Apr 2, 2024 · 4 comments
Assignees

Comments

@blythed
Copy link
Collaborator

blythed commented Apr 2, 2024

Needed for GPU/ CUDA compiled binaries.

  • Release mechanisms also uploads 2 docker-images to open docker hub
  • Use CUDA base image as base for superduperdb/cuda
@fnikolai
Copy link
Collaborator

fnikolai commented Apr 2, 2024

Summary of tasks:

  1. rename superduperdb/superduperdb to superduperdb/base
  2. introduce superduperdb/cuda_base
  3. Add an example of how users can use FROM superduperdb/base to build their custom application images.

@fnikolai
Copy link
Collaborator

fnikolai commented May 15, 2024

For cuda, the main issue that cuda drivers and nvidia-container-runtime must be installed on the host.

https://developer.nvidia.com/cuda-downloads?target_os=Linux

To check if they are installed:

import GPUtil
import numpy as np

def main():
    # Get the list of available GPUs
    gpus = GPUtil.getAvailable(order='first', limit=1, maxLoad=0.5, maxMemory=0.5, includeNan=False, excludeID=[], excludeUUID=[])

    # Check if any GPUs are available
    if gpus:
        print("GPU is available")
        # Pick the first GPU
        gpu_id = gpus[0]
        # Set CUDA_VISIBLE_DEVICES environment variable
        import os
        os.environ["CUDA_VISIBLE_DEVICES"] = str(gpu_id)

        # Example computation on GPU
        print("Running computation on GPU...")
        a = np.array([1.0, 2.0, 3.0])
        b = np.array([4.0, 5.0, 6.0])
        c = a + b
        print("Result of computation on GPU:")
        print(c)
    else:
        print("No GPU available, running computation on CPU instead")
        # Example computation on CPU
        a = np.array([1.0, 2.0, 3.0])
        b = np.array([4.0, 5.0, 6.0])
        c = a + b
        print("Result of computation on CPU:")
        print(c)

if __name__ == "__main__":
    main()

https://medium.com/@albertqueralto/enabling-cuda-capabilities-in-docker-containers-51a3566ad014

@fnikolai
Copy link
Collaborator

fnikolai commented May 15, 2024

The trick is on --gpus=all. If this is enabled, even the basic nightly version works with gpu.

docker run --gpus=all -p 8888:8888 -ti --entrypoint /bin/sh superduperdb/nightly:dec04a88
returns

$ python test_gpu.py	
GPU is available
Running computation on GPU...
Result of computation on GPU:
[5. 7. 9.]

docker run -p 8888:8888 -ti --entrypoint /bin/sh superduperdb/nightly:dec04a88

returns

superduper@8d1c84475b8f:~/superduperdb$ python test_gpu.py 
No GPU available, running computation on CPU instead
Result of computation on CPU:
[5. 7. 9.]

@fnikolai
Copy link
Collaborator

According to this image https://gitlab.com/nvidia/container-images/cuda/-/blob/master/dist/11.3.1/ubuntu2004/base/Dockerfile the only difference is a few environment variables that are set.

  • Given that the enabling GPU supports relies solely on the host, that raises the question of whether we need to separate the CPU from GPU images *

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

No branches or pull requests

2 participants