dusty-nv / jetson-containers

Machine Learning Containers for NVIDIA Jetson and JetPack-L4T
MIT License
2.09k stars 435 forks source link

How do I build a custom container? #350

Open sibyjackgrove opened 8 months ago

sibyjackgrove commented 8 months ago

Maybe this has been answered before. But I am confused by the instructions in https://github.com/dusty-nv/jetson-containers/blob/master/docs/build.md#building-external-packages If I have an application called dataimputation.py, Could you let me know if the following steps are the correct ones if I want to containerize the application by using a Dockerfile?

Build my base container.

$ ./build.sh --name my_tensorflow tensorflow2 --verbose

Create Dockerfile with my dataimputation.py application.

FROM my_tensorflow

WORKDIR app
COPY . /app

RUN pip3 install -r requirements.txt

CMD ["python3", "dataimputation.py"]

Build my external package using the Dockerfile $ ./build.sh --package-dirs=/mypackage dataimpuation

sibyjackgrove commented 8 months ago

I figured it out without using the external packages option. It seems I just need to define a Dockerfile that uses as it's base image the jetson image that I built previously.

FROM tf211_container:r35.4.1

RUN mkdir /app
WORKDIR /app

COPY ./requirements.txt ./
RUN python3 -m pip install --no-cache-dir -r requirements.txt

Then use docker build instead of build.sh to build my custom container docker build -t custom_jetson_pacakge:0.0.1 .

dusty-nv commented 8 months ago

Hi @sibyjackgrove, sorry for the delay - yes, that approach you took with making your own Dockerfile is the easiest 👍

For more complex setups, you can define your own packages in jetson-containers, which become components used in other containers in the build system: https://github.com/dusty-nv/jetson-containers/blob/master/docs/packages.md

But you can think of jetson-containers as the way to essentially build your desired base container for you to layer your application on top of.

sibyjackgrove commented 8 months ago

Hi @sibyjackgrove, sorry for the delay - yes, that approach you took with making your own Dockerfile is the easiest 👍

For more complex setups, you can define your own packages in jetson-containers, which become components used in other containers in the build system: https://github.com/dusty-nv/jetson-containers/blob/master/docs/packages.md

But you can think of jetson-containers as the way to essentially build your desired base container for you to layer your application on top of.

No worries! Thank you for confirming my approach @dusty-nv I just wanted to make sure I was not building custom containers in a sub-optimal way.

gOrca commented 3 months ago

dataimputation.py

At what point did you include your 'dataimputation.py' as part of your container? And how did you do this?