How to install 2 CUDA using Docker file and Ansible Task?

Hi everyone,

I am developing a docker container image which I have to install 2 Nvidia Cuda packages (CUDA 10.1 and CUDA 11.0) using Ansible task. I am running ansible task over Dockerfile. However, single cuda is working fine but when I tried to install second cuda it shows No package matching ‘cuda-11.0’ is available. Below are the 2 cuda ansible task. Only difference is cuda and cuda-11.0. cuda-11.0 define second cuda. P.S.This method works well in local machine to manage multiple cuda

- name: Install CUDA 10.1
  when: cuda_check is changed
  become: true
  register: cuda_installed_1
  apt:
    name:
      - cuda
    state: present
    update_cache: yes

- name: Install CUDA 11.0
  when: cuda_check is changed
  become: true
  register: cuda_installed_2
  apt:
    name:
      - cuda-11.0
    state: present
    update_cache: yes

Manage both cuda by defining the path as below:

export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:/usr/local/cuda-10.1/lib64:/usr/local/cuda-11.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

Kindly help how I can manage multiple cuda inside docker.

Setup Cuda command reference: