1

What I want to do

Let's say I want to use ModelA and ModelB. Each model's environment is inside a container Container1 and Container2. Those environment are conflicting, I cannot merge them.

I would like to use both models in the same Python script, something like:

from envA import modelA
from envB import modelB

# ... boilerplate code

outputA = modelA(dataA)
outputB = modelB(dataB)

# perform processing with outputA AND outputB

I would like to know if there is a simple way to perform this with Docker or any container techno, please?

DISCLAIMER: I am not doing production business DL. I can see that a solution could have some problems with scaling (or other stuff). In my context, I want to run this on a cluster to do some experiments, that's it.

More about conflicting environments

Namely, in one of the environment I need a specific version of CUDA to compile some components. If I take a version lower then my GPU is not supported. If I take a version above, then it does not compile (or there is a linking problem, I do not remember well).

While the other environment is running Python 3.10.9 and its base code (and libs) depend on it. So I cannot use a compatible Python version to run with the first environment.

Well, I guess I can work this out if I edit the base codes of modelA and modelB. Or if I tweak their environments. But I would like to don't spend much time on it. Plus, I find the idea of using containerA and containerB much more elegant.

What I could think of

I did not manage to find something useful online. There are a bunch of beginner Docker tutorial online, some of great BTW. But, I did not find something like that. Also, my knowledge in Docker is fairly limited.

For more context, I am doing research in Deep Learning and I conducted experiments with 2 models. Those models have very different requirements and one of them has ridiculous painful requirements. Now, I would like to perform experiments with both models, I will need both outputs.

So I am asking myself that would be super handy to just "use" my former containers from another one container (or on my host machine). In this manner, it means I can just set up each environment and have my containers working properly.

I guess the way is doing something with volume or having a volume on Docker socket? Or, I guess in industry this situation should be common, maybe there is a soft for interfacing DL models so that I can import them?

SO suggested this post but I do not use TensorFlow and, in my case, there is conflicting version of environments such as shared library (cudnn or cuda) conflict.

One working solution

On EnvA (and EnvB) I can store the outputs of my model in a dictionary with ID of the inputs as key and a torch tensor as value. Then I can output the dictionary in a .pkl file. So, in a new environment, I can open both .pkl files to have outputA and outputB. It's not exactly what I ask but it would work fine.

MufasaChan
  • 111
  • 8
  • I've done this before by hosting each model in its own Docker container at a FastAPI endpoint. Then use docker network to assign each container an IP address and send HTTP requests to it. – DWKOT Apr 24 '23 at 17:46
  • Thanks for letting me know about this solution! It interests me a lot. I barely know about FastAPI, do you have any resources for helping me making it please? I searched online, I think I can figure out by myself. But I would appreciate if you have any good links. – MufasaChan Apr 25 '23 at 05:43

0 Answers0