Bootstrap: docker
From: nvcr.io/nvidia/tlt-streamanalytics:v3.0-dp-py3

%files
    # Copies the Training spec file from the local machine to the container image
    ./tlt_training /opt/tlt_training


%post
    # Install tlt dependencies 
    pip3 install nvidia-pyindex
    pip3 install nvidia-tlt
    tlt info

    # add ngc command inorder to access ngc registry to download pretrained model...
    wget -O ngccli_cat_linux.zip https://ngc.nvidia.com/downloads/ngccli_cat_linux.zip && unzip -o ngccli_cat_linux.zip && chmod u+x ngc
    md5sum -c ngc.md5
    export PATH=$PATH:$(pwd)
    # opt/tlt_training/api-key.txt contains my username and password to ngc
    ngc config set < opt/tlt_training/api-key.txt

    #downloading the pretrained model
    mkdir -p opt/pretrained_resnet18/
    ngc registry model download-version nvidia/tlt_pretrained_object_detection:resnet18 \
                    --dest opt/pretrained_resnet18

    docker login nvcr.io -u '$oauthtoken' -p ******NTkw

    mkdir -p opt/experiment_dir_unpruned/
    
    echo "done running post"

%runscript
    systemctl status docker
    docker login nvcr.io -u '$oauthtoken' -p ******NTkw

    echo "Running from within singularity now"

    tlt yolo_v4 train -e opt/tlt_training/yolo_v4_train_resnet18_kitti.txt \
                   -r opt/experiment_dir_unpruned \
                   -k ******NTkw \
                   --gpus 1